siddhantsangwan commented on code in PR #3485:
URL: https://github.com/apache/ozone/pull/3485#discussion_r918900411


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java:
##########
@@ -672,31 +679,31 @@ private boolean moveContainer(DatanodeDetails source,
   }
 
   /**
-   * Update targets and selection criteria after a move.
+   * Update targets, sources, and selection criteria after a move.
    *
-   * @param selectedTargets  selected target datanodes
-   * @param moveSelection    the target datanode and container that has been
-   *                         just selected
-   * @param source           the source datanode
-   * @return List of updated potential targets
+   * @param moveSelection the target datanode and container that has been
+   *                      just selected
+   * @param source        the source datanode
    */
   private void updateTargetsAndSelectionCriteria(
-      Set<DatanodeDetails> selectedTargets,
       ContainerMoveSelection moveSelection, DatanodeDetails source) {
     // count source if it has not been involved in move earlier
-    if (!sourceToTargetMap.containsKey(source) &&
-        !selectedTargets.contains(source)) {
+    if (!selectedSources.contains(source)) {
       countDatanodesInvolvedPerIteration += 1;
     }
     // count target if it has not been involved in move earlier
     if (!selectedTargets.contains(moveSelection.getTargetNode())) {
       countDatanodesInvolvedPerIteration += 1;
     }
     incSizeSelectedForMoving(source, moveSelection);
-    sourceToTargetMap.put(source, moveSelection);
+    selectedContainersList.add(moveSelection.getContainerID());
+    containerFromSourceMap.put(moveSelection.getContainerID(), source);
+    containerToTargetMap.put(moveSelection.getContainerID(),
+        moveSelection.getTargetNode());

Review Comment:
   Good suggestion. Just so we can prevent such a move from happening, I've 
added a pre check to `processMoveSelection`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to