ArafatKhan2198 commented on code in PR #5782:
URL: https://github.com/apache/ozone/pull/5782#discussion_r1427960728


##########
hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/protocol/MockDatanodeDetails.java:
##########
@@ -118,11 +128,21 @@ public static DatanodeDetails randomLocalDatanodeDetails()
       return createDatanodeDetails(UUID.randomUUID().toString(),
           socket.getInetAddress().getHostName(),
           socket.getInetAddress().getHostAddress(), null,
-          socket.getLocalPort());
+          getFreePort());
     }
   }
 
   private MockDatanodeDetails() {
     throw new UnsupportedOperationException("no instances");
   }
+
+  static synchronized int getFreePort() {
+    LOG.info("### Getting free port ###");
+    int port = NEXT_PORT.getAndIncrement();
+    if (port > MAX_PORT) {
+      NEXT_PORT.set(MIN_PORT);
+      port = NEXT_PORT.getAndIncrement();
+    }
+    return port;
+  }

Review Comment:
   Thanks for the idea!
   Have made the changes.



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