You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/09/09 11:24:34 UTC

[GitHub] [ozone] siddhantsangwan commented on a change in pull request #2625: HDDS-5728. ContainerBalancer should use remaining space to calculate utilization.

siddhantsangwan commented on a change in pull request #2625:
URL: https://github.com/apache/ozone/pull/2625#discussion_r705236024



##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
##########
@@ -627,23 +633,26 @@ private double calculateAvgUtilization(List<DatanodeUsageInfo> nodes) {
     }
     clusterCapacity = aggregatedStats.getCapacity().get();
     clusterUsed = aggregatedStats.getScmUsed().get();
+    clusterRemaining = aggregatedStats.getRemaining().get();
 
-    return clusterUsed / (double) clusterCapacity;
+    return (clusterCapacity - clusterRemaining) / (double) clusterCapacity;
   }
 
   /**
-   * Calculates the utilization, that is used space divided by capacity, for
-   * the given datanodeUsageInfo.
+   * Calculates the utilization, that is (capacity - remaining) divided by
+   * capacity, for the given datanodeUsageInfo.
    *
    * @param datanodeUsageInfo DatanodeUsageInfo to calculate utilization for
    * @return Utilization value
    */
   public static double calculateUtilization(
       DatanodeUsageInfo datanodeUsageInfo) {
     SCMNodeStat stat = datanodeUsageInfo.getScmNodeStat();
+    double capacity = stat.getCapacity().get();
+    double remaining = stat.getRemaining().get();
+    double numerator = capacity - remaining;
 
-    return stat.getScmUsed().get().doubleValue() /
-        stat.getCapacity().get().doubleValue();
+    return numerator / capacity;
   }

Review comment:
       Currently the utilization api uses `compareByRemainingRatio` in `SCMNodeStat`. We could instead have a `calculateUtilization` method in the `DatanodeUsageInfo` 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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org