This is an automated email from the ASF dual-hosted git repository.

sammichen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 9023fe7  HDDS-3606. Add datanode port into the printTopology command 
output (#935)
9023fe7 is described below

commit 9023fe76b7e7b381d81f772e85d4d38fb6816b7a
Author: maobaolong <[email protected]>
AuthorDate: Tue May 19 14:20:39 2020 +0800

    HDDS-3606. Add datanode port into the printTopology command output (#935)
---
 .../apache/hadoop/hdds/scm/cli/TopologySubcommand.java | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git 
a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/TopologySubcommand.java
 
b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/TopologySubcommand.java
index 17da8e6..95a1235 100644
--- 
a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/TopologySubcommand.java
+++ 
b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/TopologySubcommand.java
@@ -116,15 +116,27 @@ public class TopologySubcommand implements Callable<Void> 
{
     });
   }
 
+  private String formatPortOutput(List<HddsProtos.Port> ports) {
+    StringBuilder sb = new StringBuilder();
+    for (int i = 0; i < ports.size(); i++) {
+      HddsProtos.Port port = ports.get(i);
+      sb.append(port.getName() + "=" + port.getValue());
+      if (i < ports.size() - 1) {
+        sb.append(",");
+      }
+    }
+    return sb.toString();
+  }
 
-  // Format "ipAddress(hostName)    networkLocation"
+  // Format "ipAddress(hostName):PortName1=PortValue1    networkLocation"
   private void printNodesWithLocation(Collection<HddsProtos.Node> nodes) {
     nodes.forEach(node -> {
       System.out.print(" " + node.getNodeID().getIpAddress() + "(" +
-          node.getNodeID().getHostName() + ")");
+          node.getNodeID().getHostName() + ")" +
+          ":" + formatPortOutput(node.getNodeID().getPortsList()));
       System.out.println("    " +
           (node.getNodeID().getNetworkLocation() != null ?
               node.getNodeID().getNetworkLocation() : "NA"));
     });
   }
-}
\ No newline at end of file
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to