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


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java:
##########
@@ -103,8 +103,18 @@ public class ContainerBalancer extends StatefulService {
   private volatile Thread currentBalancingThread;
   private Lock lock;
   private ContainerBalancerSelectionCriteria selectionCriteria;
-  private Map<DatanodeDetails, ContainerMoveSelection> sourceToTargetMap;
-  private Set<ContainerID> selectedContainers;
+
+  /*
+  Since a container can be selected only once during an iteration, these maps
+   use it as a primary key to track source to target pairings.
+  */
+  private final Map<ContainerID, DatanodeDetails> containerFromSourceMap;
+  private final Map<ContainerID, DatanodeDetails> containerToTargetMap;
+
+  private Set<DatanodeDetails> selectedTargets;
+  private Set<DatanodeDetails> selectedSources;
+  // maintaining a list of containers for testing
+  private final List<ContainerID> selectedContainersList;

Review Comment:
   This data is being used solely for testing. We can avoid storing a list of 
all containers that have been moved by doing something like this in the test, 
instead:
   ```
       int numContainers = containerBalancer.getContainerToTargetMap().size();
   
       /*
       Assuming move is called exactly once for each unique container, number of
        calls to move should equal number of unique containers. If number of
        calls to move is more than number of unique containers, at least one
        container has been re-selected.
        */
       Mockito.verify(replicationManager, times(numContainers))
           .move(any(ContainerID.class), any(DatanodeDetails.class),
               any(DatanodeDetails.class));
   
   ```



-- 
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