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


##########
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:
   This has 2 part,
   1st part,  setMaxSizeLeavingSource should be Zero as new configuration of 
2*OzoneConsts.MB
   2nd part, with default configuration which is 26GB (default), there should 
be scheduled movement as checked for size in above case.
   This compare that with default, there should be movement of unbalanced 
cluster as comment at line 567



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