Class PortUtils
java.lang.Object
com.atlassian.jira.plugins.ha.container.PortUtils
This class provides methods to check if ports are available and wait for them to become free.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidensurePortsNotInUse(Map<String, Integer> ports, String instanceId) Ensures that all specified ports are available for use.static booleanisPortInUse(int port) Checks if a specific port is currently in use on localhost.
-
Method Details
-
ensurePortsNotInUse
Ensures that all specified ports are available for use. This method will attempt to check port availability multiple times with a delay between attempts. If ports remain in use after all attempts, it will throw an exception.- Parameters:
ports- Map of port names to their corresponding port numbersinstanceId- The instance ID for logging purposes- Throws:
IllegalStateException- if any port remains in use after maximum attempts
-
isPortInUse
public static boolean isPortInUse(int port) Checks if a specific port is currently in use on localhost. This method attempts to bind to the port and returns true if the binding fails (indicating the port is in use).- Parameters:
port- The port number to check- Returns:
- true if the port is in use, false if the port is available
-