public final class NetworkAddressUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
NetworkAddressUtils.ServiceType
Different types of services that client uses to connect.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
WILDCARD_ADDRESS |
static boolean |
WINDOWS
Checks if the underlying OS is Windows.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
assertValidPort(InetSocketAddress address,
TachyonConf tachyonConf) |
static void |
assertValidPort(int port,
TachyonConf tachyonConf) |
static InetSocketAddress |
getBindAddress(NetworkAddressUtils.ServiceType service,
TachyonConf conf)
Helper method to get the
InetSocketAddress bind address on a given service. |
static InetSocketAddress |
getConnectAddress(NetworkAddressUtils.ServiceType service,
TachyonConf conf)
Helper method to get the
InetSocketAddress address for client to communicate with the
service. |
static String |
getConnectHost(NetworkAddressUtils.ServiceType service,
TachyonConf conf)
Provides an externally resolvable hostname for client to communicate with the service.
|
static String |
getFqdnHost(InetSocketAddress addr)
Get FQDN(Full Qualified Domain Name) from Java representations of network address, except
String representation which should be handled by #resolveHostName(String hostname) which will
handle the situation where hostname is null.
|
static String |
getFqdnHost(NetAddress addr)
Gets FQDN(Full Qualified Domain Name) from Tachyon representation of network address.
|
static String |
getLocalHostName(int timeout)
Gets a local host name for the host this JVM is running on
|
static String |
getLocalHostName(TachyonConf conf)
Gets a local host name for the host this JVM is running on
|
static String |
getLocalIpAddress(int timeout)
Gets a local IP address for the host this JVM is running on
|
static String |
getLocalIpAddress(TachyonConf conf)
Gets a local IP address for the host this JVM is running on
|
static int |
getPort(NetworkAddressUtils.ServiceType service,
TachyonConf conf)
Gets the port number on a given service type.
|
static int |
getThriftPort(org.apache.thrift.transport.TServerSocket thriftSocket)
Gets the port for the underline socket.
|
static ServerSocket |
getThriftSocket(org.apache.thrift.transport.TServerSocket thriftSocket)
Extracts the port from the thrift socket.
|
static InetSocketAddress |
parseInetSocketAddress(String address)
Parses InetSocketAddress from a String.
|
static TachyonURI |
replaceHostName(TachyonURI path)
Replaces and resolves the hostname in a given address or path string.
|
static String |
resolveHostName(String hostname)
Resolves a given hostname by a canonical hostname.
|
public static final String WILDCARD_ADDRESS
public static final boolean WINDOWS
public static void assertValidPort(int port,
TachyonConf tachyonConf)
public static void assertValidPort(InetSocketAddress address, TachyonConf tachyonConf)
public static InetSocketAddress getConnectAddress(NetworkAddressUtils.ServiceType service, TachyonConf conf)
InetSocketAddress address for client to communicate with the
service.service - the service name used to connectconf - the configuration of Tachyonpublic static String getConnectHost(NetworkAddressUtils.ServiceType service, TachyonConf conf)
| Specified Hostname | Specified Bind Host | Returned Connect Host |
|---|---|---|
| hostname | hostname | hostname |
| not defined | hostname | hostname |
| hostname | 0.0.0.0 or not defined | hostname |
| not defined | 0.0.0.0 or not defined | localhost |
service - Service type used to connectconf - Tachyon configuration used to look up the host resolution timeoutpublic static int getPort(NetworkAddressUtils.ServiceType service, TachyonConf conf)
service - Service type used to connectconf - Tachyon configurationpublic static InetSocketAddress getBindAddress(NetworkAddressUtils.ServiceType service, TachyonConf conf)
InetSocketAddress bind address on a given service.
Host bind information searching order:
service - the service name used to connectconf - the configuration of Tachyonpublic static String getLocalHostName(TachyonConf conf)
conf - Tachyon configuration used to look up the host resolution timeoutpublic static String getLocalHostName(int timeout)
timeout - Timeout in milliseconds to use for checking that a possible local host is
reachablepublic static String getLocalIpAddress(TachyonConf conf)
conf - Tachyon configurationpublic static String getLocalIpAddress(int timeout)
timeout - Timeout in milliseconds to use for checking that a possible local IP is
reachablepublic static TachyonURI replaceHostName(TachyonURI path) throws UnknownHostException
path - an address or path string, e.g., "hdfs://host:port/dir", "file:///dir", "/dir".UnknownHostException - if the hostname cannot be resolved.public static String resolveHostName(String hostname) throws UnknownHostException
hostname - the input hostname, which could be an alias.UnknownHostException - if the given hostname cannot be resolved.public static String getFqdnHost(InetSocketAddress addr)
addr - the input network address representation, can not be nullpublic static String getFqdnHost(NetAddress addr) throws UnknownHostException
addr - the input network address representationUnknownHostException - if the host is not knownpublic static int getThriftPort(org.apache.thrift.transport.TServerSocket thriftSocket)
getThriftSocket(org.apache.thrift.transport.TServerSocket), so reflection will be used
to get the port.public static ServerSocket getThriftSocket(org.apache.thrift.transport.TServerSocket thriftSocket)
RuntimeException - if reflection calls failpublic static InetSocketAddress parseInetSocketAddress(String address) throws IOException
address - socket address to parseIOException - if the socket address is invalidCopyright © 2015. All Rights Reserved.