@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() |
private static InetAddress |
getIpAddress(Addressing.AddressSelectionCondition condition) |
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 Addressing()
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:1234public static String parseHostname(String hostAndPort)
hostAndPort - Formatted as <hostname> ':' <port>hostAndPortpublic static int parsePort(String hostAndPort)
hostAndPort - Formatted as <hostname> ':' <port>hostAndPortpublic static InetAddress getIpAddress() throws SocketException
SocketExceptionpublic static InetAddress getIp4Address() throws SocketException
SocketExceptionpublic static InetAddress getIp6Address() throws SocketException
SocketExceptionprivate static InetAddress getIpAddress(Addressing.AddressSelectionCondition condition) throws SocketException
SocketExceptionpublic static boolean isLocalAddress(InetAddress addr)
addr - address to check if it is local node's addressCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.