@InterfaceAudience.Private public class Addressing extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Addressing.AddressSelectionCondition
Interface for AddressSelectionCondition to check if address is acceptable
|
Modifier and Type | Field and Description |
---|---|
static String |
HOSTNAME_PORT_SEPARATOR |
static String |
VALID_PORT_REGEX |
Constructor and Description |
---|
Addressing() |
Modifier and Type | Method and Description |
---|---|
static String |
createHostAndPortStr(String hostname,
int port) |
static InetSocketAddress |
createInetSocketAddressFromHostAndPortStr(String hostAndPort) |
static InetAddress |
getIp4Address() |
static InetAddress |
getIp6Address() |
static InetAddress |
getIpAddress() |
static boolean |
isLocalAddress(InetAddress addr)
Given an InetAddress, checks to see if the address is a local address, by comparing the address
with all the interfaces on the node.
|
static String |
parseHostname(String hostAndPort) |
static int |
parsePort(String hostAndPort) |
public static final String VALID_PORT_REGEX
public static final String HOSTNAME_PORT_SEPARATOR
public static InetSocketAddress createInetSocketAddressFromHostAndPortStr(String hostAndPort)
hostAndPort
- Formatted as <hostname> ':' <port>
public static String createHostAndPortStr(String hostname, int port)
hostname
- Server hostnameport
- Server porthostname
and
port
in following
form: <hostname> ':' <port>
. For example, if hostname
is example.org
and port is 1234, this method will return
example.org:1234
public static String parseHostname(String hostAndPort)
hostAndPort
- Formatted as <hostname> ':' <port>
hostAndPort
public static int parsePort(String hostAndPort)
hostAndPort
- Formatted as <hostname> ':' <port>
hostAndPort
public static InetAddress getIpAddress() throws SocketException
SocketException
public static InetAddress getIp4Address() throws SocketException
SocketException
public static InetAddress getIp6Address() throws SocketException
SocketException
public static boolean isLocalAddress(InetAddress addr)
addr
- address to check if it is local node's address