You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/05/03 19:23:00 UTC

[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #6872: Make zookeeper, kafka, controller, broker use random port for integration tests

Jackie-Jiang commented on a change in pull request #6872:
URL: https://github.com/apache/incubator-pinot/pull/6872#discussion_r625311279



##########
File path: pinot-spi/src/main/java/org/apache/pinot/spi/utils/NetUtils.java
##########
@@ -57,4 +59,29 @@ public static String getHostnameOrAddress() {
       }
     }
   }
+
+  /**
+   * Find an open port.
+   * @return an open port
+   * @throws IOException
+   */
+  public static int findOpenPort()
+      throws IOException {
+    try (ServerSocket socket = new ServerSocket(0)) {
+      return socket.getLocalPort();
+    }
+  }
+
+  /**
+   * Find an open port,otherwise use given default port.
+   * @param defaultPort
+   * @return an open port otherwise default port
+   */
+  public static int findOpenPort(int defaultPort) {

Review comment:
       Can we first try with the default port, and use open port only when default is occupied? This can save the step of looking for port when using integration test to debug stuff.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org