szetszwo commented on code in PR #9587:
URL: https://github.com/apache/ozone/pull/9587#discussion_r2662167754


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/policy/DefaultVolumeChoosingPolicy.java:
##########
@@ -67,24 +67,41 @@ public Pair<HddsVolume, HddsVolume> 
chooseVolume(MutableVolumeSet volumeSet,
           .sorted(Comparator.comparingDouble(VolumeFixedUsage::getUtilization))
           .collect(Collectors.toList());
 
-      // Calculate the actual threshold and check src
-      final double actualThreshold = getIdealUsage(volumeUsages) + 
thresholdPercentage / 100;
-      final VolumeFixedUsage src = volumeUsages.get(volumeUsages.size() - 1);
-      if (src.getUtilization() < actualThreshold) {
-        return null; // all volumes are under the threshold
+      // Calculate ideal usage and threshold range
+      final double idealUsage = getIdealUsage(volumeUsages);
+      final double actualThreshold = thresholdPercentage / 100.0;
+      final double lowerThreshold = idealUsage - actualThreshold;
+      final double upperThreshold = idealUsage + actualThreshold;
+
+      // Get highest and lowest utilization volumes
+      final VolumeFixedUsage highestUsage = 
volumeUsages.get(volumeUsages.size() - 1);
+      final VolumeFixedUsage lowestUsage = volumeUsages.get(0);
+
+      // Only return null if highest is below upper threshold AND lowest is 
above lower threshold
+      // This means all volumes are strictly within the range (not at 
boundaries)
+      if (highestUsage.getUtilization() < upperThreshold && 
+          lowestUsage.getUtilization() > lowerThreshold) {
+        // All volumes are strictly within threshold range, no balancing needed
+        return null;

Review Comment:
   👍 It is good to filter out this case first.



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