sreejasahithi commented on code in PR #11037:
URL: https://github.com/apache/ozone/pull/11037#discussion_r3796107580


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancerTask.java:
##########
@@ -1130,15 +1129,14 @@ public static double 
calculateAvgUtilization(List<DatanodeUsageInfo> nodes) {
           "ContainerBalancer.");
       return 0;
     }
-    SCMNodeStat aggregatedStats = new SCMNodeStat(
-        0, 0, 0, 0, 0, 0);
+    long totalCapacity = 0;
+    long totalRemaining = 0;
     for (DatanodeUsageInfo node : nodes) {
-      aggregatedStats.add(node.getScmNodeStat());
+      totalCapacity += node.getScmNodeStat().getCapacity().get();
+      totalRemaining += node.getScmNodeStat().getRemaining().get();
     }
-    long clusterCapacity = aggregatedStats.getCapacity().get();
-    long clusterRemaining = aggregatedStats.getRemaining().get();
-
-    return (clusterCapacity - clusterRemaining) / (double) clusterCapacity;
+    return ContainerBalancerClusterAnalyzer.calculateAvgUtilization(
+        totalCapacity, totalRemaining);
   }

Review Comment:
   keeps its existing `List<DatanodeUsageInfo>` wrapper, aggregates node stats, 
and delegate to the shared core method.
   you can do :
   ```
   return ContainerBalancerClusterAnalyzer.calculateAvgUtilization(
           clusterCapacity, clusterRemaining);
   ```
   



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