ChenSammi commented on code in PR #8972:
URL: https://github.com/apache/ozone/pull/8972#discussion_r2306947601


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/DiskBalancerService.java:
##########
@@ -642,37 +643,38 @@ public DiskBalancerInfo getDiskBalancerInfo() {
   }
 
   public long calculateBytesToMove(MutableVolumeSet inputVolumeSet) {
-    long bytesPendingToMove = 0;
-    long totalFreeSpace = 0;
-    long totalCapacity = 0;
-
-    for (HddsVolume volume : 
StorageVolumeUtil.getHddsVolumesList(inputVolumeSet.getVolumesList())) {
-      totalFreeSpace += volume.getCurrentUsage().getAvailable();
-      totalCapacity += volume.getCurrentUsage().getCapacity();
-    }
-
-    if (totalCapacity == 0) {
+    // If there are no available volumes, return 0 bytes to move
+    if (inputVolumeSet.getVolumesList().isEmpty()) {
       return 0;
     }
 
-    double datanodeUtilization = ((double) (totalCapacity - totalFreeSpace)) / 
totalCapacity;
+    double idealUsage = inputVolumeSet.getIdealUsage();

Review Comment:
   Gargi, let's move the getIdealUsage() into DiskBalancer code.  We use the 
volumeMap value in MutableVolumeSet twice, one for the getIdealUsage(), and one 
below to calculate each volume's density.  volumeMap can change between them. 
So let's get immutable list of volumes, and use that for both ideal usage 
calculation and per volume density calculation. 



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