Gargi-jais11 commented on code in PR #10755:
URL: https://github.com/apache/ozone/pull/10755#discussion_r3600447350


##########
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:
   I believe ur concern is correct. So what we can do is as @rich7420 suggested 
to add an explicit **-id flag** for supporting node-uuid would be a better 
option. Then user can easily distinguish that if scm is down they cannot use 
`--id` or `--in-service-datanodes`, rather they need to specify hostname or 
ipAddress.
   This way user can use uuid when scm is up else they are bound to use 
hostnames.
   
   @ChenSammi @slfan1989 what do u think about this approach?



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