@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)
Create a host-and-port string
|
static InetSocketAddress |
createInetSocketAddressFromHostAndPortStr(String hostAndPort)
Create a socket address
|
static InetAddress |
getIp4Address() |
static InetAddress |
getIp6Address() |
static InetAddress |
getIpAddress() |
static String |
inetSocketAddress2String(InetSocketAddress address)
Given an InetSocketAddress object returns a String represent of it.
|
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)
Parse the hostname portion of a host-and-port string
|
static int |
parsePort(String hostAndPort)
Parse the port portion of a host-and-port string
|
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 addresspublic static String inetSocketAddress2String(InetSocketAddress address)
address
- address to convert to a "host:port" String.Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.