Gargi-jais11 commented on code in PR #9858:
URL: https://github.com/apache/ozone/pull/9858#discussion_r2916101702


##########
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:
   During testing I found one bug when running this 
[test](https://github.com/Gargi-jais11/ozone/blob/f3a50d72cfdede31c2a05ee130227d5dc0e80f79/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/node/TestDiskBalancerPolicyPerformance.java#L254-L278)
 .
   
   When a container is removed from the containerSet after the iterator is 
cached then it will still point old container as a valid one. So I added a 
check in 
[`DefaultContainerChoosingPolicy`](https://github.com/Gargi-jais11/ozone/blob/f3a50d72cfdede31c2a05ee130227d5dc0e80f79/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/policy/DefaultContainerChoosingPolicy.java#L170-L172
 ). This was a catch after refactoring.
   
   And I am working to make the policy work more realistic.
   



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