slfan1989 commented on code in PR #10267:
URL: https://github.com/apache/ozone/pull/10267#discussion_r3245512923
##########
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();
Review Comment:
@szetszwo Thanks for the suggestion! Addressed by validating each volume’s
capacity and effective used before calculating ideal usage, and added tests for
the new edge cases.
--
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]