chungen0126 commented on code in PR #8239:
URL: https://github.com/apache/ozone/pull/8239#discussion_r2072548979


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/node/TestDiskBalancer.java:
##########
@@ -86,6 +90,53 @@ public void testDatanodeDiskBalancerReport() throws 
IOException {
         >= reportProtoList.get(1).getCurrentVolumeDensitySum());
   }
 
+  @Test
+  public void testDiskBalancerStopAfterEven() throws IOException,
+      InterruptedException, TimeoutException {
+    String datanodeHostName1 = cluster.getStorageContainerManager()
+        .getScmNodeManager()
+        .getAllNodes()
+        .get(0)
+        .getHostName();
+
+    // Start the DiskBalancer with specific parameters
+    diskBalancerManager.startDiskBalancer(
+        Optional.of(10.0), // threshold
+        Optional.of(10L),  // bandwidth in MB
+        Optional.of(5),    // parallel threads
+        Optional.of(true), // stopAfterDiskEven
+        Optional.of(Collections.singletonList(datanodeHostName1))//apply to 
one datanode
+    );
+
+    // Wait until the DiskBalancer status becomes RUNNING for that datanode
+    GenericTestUtils.waitFor(() -> {
+      try {
+        List<HddsProtos.DatanodeDiskBalancerInfoProto> statusList =
+            
storageClient.getDiskBalancerStatus(Optional.of(Collections.singletonList(datanodeHostName1)),
+                Optional.empty());
+
+        return statusList.size() == 1 && 
statusList.get(0).getNode().getHostName().equals(datanodeHostName1) &&
+            statusList.get(0).getRunningStatus() == 
HddsProtos.DiskBalancerRunningStatus.RUNNING;
+      } catch (IOException e) {
+        return false;
+      }
+    }, 5000, 60000); // poll every 5s, timeout after 60s

Review Comment:
   Here is another idea, we could set the interval to a higher value and run 
the disk balancer manually. Add the following lines while the disk balancer is 
running.
   
   ```
       cluster.getHddsDatanodes().forEach(datanode -> {
         try {
           
datanode.getDatanodeStateMachine().getContainer().getDiskBalancerService().runPeriodicalTaskNow();
         } catch (Exception e) {
           throw new RuntimeException(e);
         }
       });
   ```



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