slfan1989 commented on code in PR #10267:
URL: https://github.com/apache/ozone/pull/10267#discussion_r3245537661


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/DiskBalancerVolumeCalculation.java:
##########
@@ -70,13 +70,22 @@ public static List<VolumeFixedUsage> 
getVolumeUsages(MutableVolumeSet volumeSet,
    * @throws IllegalArgumentException if total capacity is zero
    */
   public static double getIdealUsage(List<VolumeFixedUsage> volumes) {
+    if (volumes == null || volumes.isEmpty()) {
+      return 0.0;
+    }
+
     long totalCapacity = 0L, totalEffectiveUsed = 0L;
-    
+
     for (VolumeFixedUsage volumeUsage : volumes) {
       totalCapacity += volumeUsage.getUsage().getCapacity();
       totalEffectiveUsed += volumeUsage.getEffectiveUsed();
     }
-    
+
+    if (totalCapacity <= 0) {

Review Comment:
   Updated. `totalCapacity == 0` now returns `0.0` for consistency with the 
empty volume case.



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