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


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/node/TestDiskBalancerPolicyPerformance.java:
##########
@@ -181,90 +177,165 @@ private void testPolicyPerformance(String policyName, 
ContainerChoosingPolicy po
     for (int i = 0; i < NUM_THREADS; i++) {
       executor.submit(() -> {
         try {
-          long threadStart = System.nanoTime();
-          int containerChosen = 0;
-          int containerNotChosen = 0;
+          int containerCandidateChosen = 0;
+          int containerCandidateNotChosen = 0;
           int failures = 0;
-          // Choose a random volume
-          HddsVolume srcVolume = volumes.get(rand.nextInt(NUM_VOLUMES));
-          HddsVolume destVolume;
-
-          do {
-            destVolume = volumes.get(rand.nextInt(NUM_VOLUMES));
-          } while (srcVolume.equals(destVolume));
 
           for (int j = 0; j < NUM_ITERATIONS; j++) {
+            // Block all volumes except the highest-util (source) - no 
destination has space
+            if (rand.nextDouble() < 0.05 && volumes.size() >= 2) {
+              List<HddsVolume> sorted = new ArrayList<>(volumes);
+              sorted.sort(Comparator.comparingDouble(v ->
+                  v.getCurrentUsage().getUsedSpace() / (double) Math.max(1, 
v.getCurrentUsage().getCapacity())));
+              for (int k = 0; k < sorted.size() - 1; k++) {
+                HddsVolume v = sorted.get(k);
+                long avail = v.getCurrentUsage().getAvailable();
+                if (avail > 0) {
+                  v.incCommittedBytes(avail);

Review Comment:
   > while the policy sorts by effective utilization (including deltaMap). 
   
   Policy sorts consider both deltaMap and CommittedBytes. CommittedBytes is 
increased with all available space here. 
   
   Please refactor this part, to make it more reasonable. And please find out 
why there are far few nulls than expected. 



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