org.fusesource.fabric.utils
Class Ports

java.lang.Object
  extended by org.fusesource.fabric.utils.Ports

public class Ports
extends java.lang.Object


Field Summary
static int DEFAULT_HOST_SSH_PORT
           
static int DEFAULT_KARAF_SSH_PORT
           
static int DEFAULT_RMI_REGISTRY_PORT
           
static int DEFAULT_RMI_SERVER_PORT
           
static int DEFAULT_ZOOKEEPER_ELECTION_PORT
           
static int DEFAULT_ZOOKEEPER_PEER_PORT
           
static int DEFAULT_ZOOKEEPER_SERVER_PORT
           
static int MAX_PORT_NUMBER
           
static int MIN_PORT_NUMBER
           
static java.lang.String PORT_PATTERN
           
 
Method Summary
static int extractPort(java.lang.String address)
          Extracts the port from an addrees.
static int findFreeLocalPort(java.util.List<java.lang.Integer> usedPorts, int port, boolean checkIfAvailable)
          Finds a the next free local port, based on the list of used ports and the ability to directly check if port is free.
static int findPort(java.util.Map<java.lang.String,java.util.List<java.lang.Integer>> usedPorts, java.lang.String ip, int port)
          Finds a port based on the given ip and the used ports for that ip.
static boolean isPortFree(int port)
          Checks if a local port is free.
static int mapPortToRange(int port, int minimumPort, int maximumPort)
          Maps the target port inside a port range.
static int mapPortToRange(int port, java.lang.String minimumPort, java.lang.String maximumPort)
          Maps the target port inside a port range.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_HOST_SSH_PORT

public static final int DEFAULT_HOST_SSH_PORT
See Also:
Constant Field Values

DEFAULT_KARAF_SSH_PORT

public static final int DEFAULT_KARAF_SSH_PORT
See Also:
Constant Field Values

DEFAULT_ZOOKEEPER_SERVER_PORT

public static final int DEFAULT_ZOOKEEPER_SERVER_PORT
See Also:
Constant Field Values

DEFAULT_ZOOKEEPER_PEER_PORT

public static final int DEFAULT_ZOOKEEPER_PEER_PORT
See Also:
Constant Field Values

DEFAULT_ZOOKEEPER_ELECTION_PORT

public static final int DEFAULT_ZOOKEEPER_ELECTION_PORT
See Also:
Constant Field Values

DEFAULT_RMI_SERVER_PORT

public static final int DEFAULT_RMI_SERVER_PORT
See Also:
Constant Field Values

DEFAULT_RMI_REGISTRY_PORT

public static final int DEFAULT_RMI_REGISTRY_PORT
See Also:
Constant Field Values

MIN_PORT_NUMBER

public static final int MIN_PORT_NUMBER
See Also:
Constant Field Values

MAX_PORT_NUMBER

public static final int MAX_PORT_NUMBER
See Also:
Constant Field Values

PORT_PATTERN

public static final java.lang.String PORT_PATTERN
See Also:
Constant Field Values
Method Detail

findPort

public static int findPort(java.util.Map<java.lang.String,java.util.List<java.lang.Integer>> usedPorts,
                           java.lang.String ip,
                           int port)
Finds a port based on the given ip and the used ports for that ip.

Parameters:
usedPorts -
ip -
port -
Returns:

findFreeLocalPort

public static int findFreeLocalPort(java.util.List<java.lang.Integer> usedPorts,
                                    int port,
                                    boolean checkIfAvailable)
Finds a the next free local port, based on the list of used ports and the ability to directly check if port is free.

Parameters:
usedPorts -
port -
checkIfAvailable -
Returns:

mapPortToRange

public static int mapPortToRange(int port,
                                 int minimumPort,
                                 int maximumPort)
Maps the target port inside a port range.

Parameters:
port -
minimumPort -
maximumPort -
Returns:

mapPortToRange

public static int mapPortToRange(int port,
                                 java.lang.String minimumPort,
                                 java.lang.String maximumPort)
Maps the target port inside a port range.

Parameters:
port -
minimumPort -
maximumPort -
Returns:

isPortFree

public static boolean isPortFree(int port)
Checks if a local port is free.

Parameters:
port -
Returns:

extractPort

public static int extractPort(java.lang.String address)
Extracts the port from an addrees.

Parameters:
address -
Returns:


Copyright © 2013 Red Hat. All Rights Reserved.