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


##########
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DiskBalancerStartSubcommand.java:
##########
@@ -56,28 +59,62 @@ public class DiskBalancerStartSubcommand extends 
AbstractDiskBalancerSubCommand
       arity = "1")
   private Boolean stopAfterDiskEven;
 
+  // Track nodes that are already running for display purposes (using Set to 
avoid duplicates)
+  private final Set<String> alreadyRunningNodes = new LinkedHashSet<>();
+
   @Override
   protected Object executeCommand(String hostName) throws IOException {
     DiskBalancerProtocol diskBalancerProxy = DiskBalancerSubCommandUtil
         .getSingleNodeDiskBalancerProxy(hostName);
     try {
-      DiskBalancerConfigurationProto config = buildConfigProto();
-      diskBalancerProxy.startDiskBalancer(config);
+      // Check if DiskBalancer is already running before starting
+      DatanodeDiskBalancerInfoProto status = 
diskBalancerProxy.getDiskBalancerInfo();
+      String dnHostname = 
DiskBalancerSubCommandUtil.getDatanodeHostname(hostName);
       
-      Map<String, Object> result = new LinkedHashMap<>();
-      result.put("datanode", hostName);
-      result.put("action", "start");
-      result.put("status", "success");
-      Map<String, Object> configMap = getConfigurationMap();
-      if (configMap != null && !configMap.isEmpty()) {
-        result.put("configuration", configMap);
+      if (status.getRunningStatus() == DiskBalancerRunningStatus.RUNNING ||

Review Comment:
   Please do not do the filtering. 
   
   It's ok to send the start command again to a DN which has disk balancer 
running, and doesn't response with "*** is already running".   It's called API 
idenpotent.  
   
   Further more, filter DN at client side is inaccurate. There is chance that 
DN changes to STOPPED state after return the status.  
   
   



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