ChenSammi commented on code in PR #9712:
URL: https://github.com/apache/ozone/pull/9712#discussion_r2908982351
##########
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DiskBalancerSubCommandUtil.java:
##########
@@ -108,16 +109,55 @@ public static List<String>
getAllOperableNodesClientRpcAddress(
}
Port port = details.getPort(Port.Name.CLIENT_RPC);
if (port != null) {
- // Use IP address for reliable connection (hostnames with underscores
may not be valid)
- addresses.add(details.getIpAddress() + ":" + port.getValue());
+ String address = details.getIpAddress() + ":" + port.getValue();
+ String display = getDatanodeHostAndIp(
+ details.getHostName(), details.getIpAddress(), port.getValue());
+ addressToDisplay.put(address, display);
} else {
System.out.printf("host: %s(%s) %s port not found%n",
details.getHostName(), details.getIpAddress(),
Port.Name.CLIENT_RPC.name());
}
}
- return addresses;
+ return addressToDisplay;
+ }
+
+ /**
+ * Extracts hostname, IP address, and port from a DatanodeDetailsProto of
status and report.
+ *
+ * @param nodeProto the DatanodeDetailsProto from the diskbalancer info
+ * @return array with [hostname, ipAddress, port] where port is the
CLIENT_RPC port
+ */
+ public static String[] extractHostIpAndPort(HddsProtos.DatanodeDetailsProto
nodeProto) {
+ String hostname = nodeProto.getHostName();
+ String ipAddress = nodeProto.getIpAddress();
+ int port = nodeProto.getPortsList().stream()
+ .filter(p -> p.getName().equals(
+ DatanodeDetails.Port.Name.CLIENT_RPC.name()))
+ .mapToInt(HddsProtos.Port::getValue)
+ .findFirst()
+ .orElse(19864); // Default port if not found
Review Comment:
Use HDDS_DATANODE_CLIENT_PORT_DEFAULT instead of hard code port number.
--
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]