Class PortUtils

java.lang.Object
com.atlassian.jira.plugins.ha.container.PortUtils

public class PortUtils extends Object
This class provides methods to check if ports are available and wait for them to become free.
  • Method Details

    • ensurePortsNotInUse

      public static void ensurePortsNotInUse(Map<String,Integer> ports, String instanceId)
      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 numbers
      instanceId - 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