ivandika3 commented on code in PR #6655:
URL: https://github.com/apache/ozone/pull/6655#discussion_r1844913451


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/protocol/DatanodeDetails.java:
##########
@@ -448,11 +449,15 @@ public HddsProtos.DatanodeDetailsProto 
getProtoBufMessage() {
   }
 
   public HddsProtos.DatanodeDetailsProto toProto(int clientVersion) {
-    return toProtoBuilder(clientVersion).build();
+    return toProtoBuilder(clientVersion, Collections.emptySet()).build();
+  }
+
+  public HddsProtos.DatanodeDetailsProto toProto(int clientVersion, 
Set<Port.Name> requiredPorts) {
+    return toProtoBuilder(clientVersion, requiredPorts).build();
   }
 
   public HddsProtos.DatanodeDetailsProto.Builder toProtoBuilder(
-      int clientVersion) {
+      int clientVersion, Set<Port.Name> requiredPorts) {

Review Comment:
   Nit: Let's add javadocs here and specify that empty set means that all ports 
will be included.



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/protocol/DatanodeDetails.java:
##########
@@ -492,14 +497,19 @@ public HddsProtos.DatanodeDetailsProto.Builder 
toProtoBuilder(
         ClientVersion.fromProtoValue(clientVersion)
         .compareTo(VERSION_HANDLES_UNKNOWN_DN_PORTS) >= 0;
     for (Port port : ports) {
-      if (handlesUnknownPorts || Name.V0_PORTS.contains(port.getName())) {
-        builder.addPorts(port.toProto());
-      } else {
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("Skip adding {} port {} to proto message for client v{}",
-              port.getName(), port.getValue(), clientVersion);
+      if (requiredPorts.isEmpty() || requiredPorts.contains(port.name)) {
+        if (handlesUnknownPorts || Name.V0_PORTS.contains(port.getName())) {
+          builder.addPorts(port.toProto());
+        } else {
+          if (LOG.isDebugEnabled()) {
+            LOG.debug("Skip adding {} port {} to proto message for client v{}",
+                port.getName(), port.getValue(), clientVersion);
+          }
         }
       }

Review Comment:
   Nit: Let's add another debug log in an `else` block for the case where the 
non required ports are skipped.



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