DaveTeng0 commented on code in PR #3904:
URL: https://github.com/apache/ozone/pull/3904#discussion_r1009985810


##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/balancer/TestContainerBalancerTask.java:
##########
@@ -543,6 +543,47 @@ public void balancerShouldObeyMaxSizeEnteringTargetLimit()
         .isEmpty());
   }
 
+  @Test
+  public void balancerShouldObeyMaxSizeLeavingSourceLimit()
+      throws IllegalContainerBalancerStateException, IOException,
+      InvalidContainerBalancerConfigurationException, TimeoutException {
+    conf.set("ozone.scm.container.size", "1MB");
+    balancerConfiguration =
+        conf.getObject(ContainerBalancerConfiguration.class);
+    balancerConfiguration.setThreshold(10);
+    balancerConfiguration.setMaxDatanodesPercentageToInvolvePerIteration(100);
+    balancerConfiguration.setMaxSizeToMovePerIteration(50 * STORAGE_UNIT);
+
+    // no source containers should be selected when the limit is just 2 MB
+    balancerConfiguration.setMaxSizeLeavingSource(2 * OzoneConsts.MB);
+    startBalancer(balancerConfiguration);
+
+    Assertions.assertFalse(containerBalancerTask.getUnBalancedNodes()
+        .isEmpty());
+    Assertions.assertTrue(containerBalancerTask.getContainerToSourceMap()
+        .isEmpty());
+    stopBalancer();
+
+    // some containers should be selected when using default values
+    OzoneConfiguration ozoneConfiguration = new OzoneConfiguration();
+    ContainerBalancerConfiguration cbc = ozoneConfiguration.
+        getObject(ContainerBalancerConfiguration.class);
+    cbc.setBalancingInterval(1);
+    ContainerBalancer sb = new ContainerBalancer(scm);
+    containerBalancerTask = new ContainerBalancerTask(scm, 0, sb,
+        sb.getMetrics(), cbc);
+    containerBalancerTask.run();
+
+    stopBalancer();
+    // balancer should have identified unbalanced nodes
+    Assertions.assertFalse(containerBalancerTask.getUnBalancedNodes()
+        .isEmpty());
+    Assertions.assertFalse(containerBalancerTask.getContainerToSourceMap()
+        .isEmpty());
+    Assertions.assertTrue(0 !=
+        containerBalancerTask.getSizeScheduledForMoveInLatestIteration());

Review Comment:
   sorry! just for myself learning! why the number is not 0? (is it because we 
set etMaxSizeLeavingSource(2 * OzoneConsts.MB)?) 
   thanks!



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