Package org.apache.pinot.spi.utils
Class NetUtils
- java.lang.Object
-
- org.apache.pinot.spi.utils.NetUtils
-
public class NetUtils extends Object
-
-
Method Summary
Modifier and Type Method Description static booleanavailable(int port)Checks to see if a specific port is available.static intfindOpenPort()Find an open port.static intfindOpenPort(int basePort)Find the first open port from default port in an incremental order.static StringgetHostAddress()Get the ip address of local host.static StringgetHostnameOrAddress()Get the hostname or IP address.
-
-
-
Method Detail
-
getHostAddress
public static String getHostAddress() throws SocketException, UnknownHostException
Get the ip address of local host.- Throws:
SocketExceptionUnknownHostException
-
getHostnameOrAddress
public static String getHostnameOrAddress()
Get the hostname or IP address.- Returns:
- The hostname if available, otherwise a dotted quad address. Returns null if neither can be determined.
-
findOpenPort
public static int findOpenPort() throws IOExceptionFind an open port.- Returns:
- an open port
- Throws:
IOException
-
findOpenPort
public static int findOpenPort(int basePort)
Find the first open port from default port in an incremental order.- Parameters:
basePort-- Returns:
- an open port
-
available
public static boolean available(int port)
Checks to see if a specific port is available.- Parameters:
port- the port to check for availability
-
-