slfan1989 commented on code in PR #10755:
URL: https://github.com/apache/ozone/pull/10755#discussion_r3600003373


##########
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/AbstractDiskBalancerSubCommand.java:
##########
@@ -154,11 +184,51 @@ private List<String> getTargetDatanodes() {
     if (options.isInServiceDatanodes()) {
       return getAllInServiceDatanodes();
     } else {
-      datanodeDisplayNames = null;  // Non-batch: use user input as-is, no SCM 
for formatting
-      return options.getDatanodes();
+      return resolveExplicitDatanodeAddresses(options.getDatanodes());
     }
   }
 
+  /**
+   * Resolves datanode UUIDs to CLIENT_RPC addresses via SCM.
+   * Hostname and host:port arguments are passed through unchanged.
+   */
+  private List<String> resolveExplicitDatanodeAddresses(List<String> nodeArgs) 
{
+    if 
(nodeArgs.stream().noneMatch(DiskBalancerSubCommandUtil::isDatanodeUuid)) {
+      datanodeDisplayNames = null;
+      return nodeArgs;
+    }
+
+    Map<String, String> displayNames = new LinkedHashMap<>();
+    List<String> resolvedAddresses = new ArrayList<>();
+    try (ScmClient scmClient = new ContainerOperationClient(new 
OzoneConfiguration())) {
+      for (String nodeArg : nodeArgs) {
+        try {
+          DiskBalancerSubCommandUtil.DatanodeTarget target =
+              DiskBalancerSubCommandUtil.resolveDatanodeTarget(scmClient, 
nodeArg);
+          resolvedAddresses.add(target.getClientRpcAddress());
+          displayNames.put(target.getClientRpcAddress(), 
target.getDisplayName());
+        } catch (IOException e) {
+          addResolutionFailure(nodeArg, e.getMessage());
+        }
+      }
+    } catch (IOException e) {
+      System.err.printf("Error resolving datanode address(es). %n%s%n", 
e.getMessage());
+      return null;
+    }

Review Comment:
   The current behavior is probably acceptable, but I wonder if we can preserve 
non-UUID targets when SCM resolution fails. Host/address arguments do not need 
SCM, so mixed inputs could still partially succeed.



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