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


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java:
##########
@@ -815,10 +822,12 @@ private void resetState() {
     this.clusterCapacity = 0L;
     this.clusterUsed = 0L;
     this.clusterRemaining = 0L;
-    this.selectedContainers.clear();
     this.overUtilizedNodes.clear();
     this.underUtilizedNodes.clear();
     this.unBalancedNodes.clear();
+    this.containerFromSourceMap.clear();
+    this.containerToTargetMap.clear();
+    this.selectedContainersList.clear();

Review Comment:
   We're creating new objects for these two references in `doIteration()`:
   ```
     private IterationResult doIteration() {
       // note that potential and selected targets are updated in the following
       // loop
       //TODO(jacksonyao): take withinThresholdUtilizedNodes as candidate for 
both
       // source and target
       findSourceStrategy.reInitialize(getPotentialSources(), config, 
lowerLimit);
       List<DatanodeUsageInfo> potentialTargets = getPotentialTargets();
       findTargetStrategy.reInitialize(potentialTargets, config, upperLimit);
   
       selectedTargets = new HashSet<>(potentialTargets.size());
       selectedSources = new HashSet<>(getPotentialSources().size());
   ```
   Is it preferable to clear and reset them instead?



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