@InterfaceAudience.Private public class Addressing extends Object
限定符和类型 | 类和说明 |
---|---|
static interface |
Addressing.AddressSelectionCondition
Interface for AddressSelectionCondition to check if address is acceptable
|
限定符和类型 | 字段和说明 |
---|---|
static String |
HOSTNAME_PORT_SEPARATOR |
static String |
VALID_PORT_REGEX |
构造器和说明 |
---|
Addressing() |
限定符和类型 | 方法和说明 |
---|---|
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 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 addressCopyright © 2007–2019 The Apache Software Foundation. All rights reserved.