public final class NetworkUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
getFqdnHost(InetSocketAddress addr)
Get FQDN(Full Qualified Domain Name) from representations of network address in Tachyon, 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) |
static String |
getLocalHostName() |
static String |
getLocalIpAddress() |
static int |
getPort(org.apache.thrift.transport.TNonblockingServerSocket thriftSocket)
Gets the port for the underline socket.
|
static ServerSocket |
getSocket(org.apache.thrift.transport.TNonblockingServerSocket thriftSocket)
Extracts the port from the thrift socket.
|
static TachyonURI |
replaceHostName(TachyonURI path)
Replace and resolve the hostname in a given address or path string.
|
static String |
resolveHostName(String hostname)
Resolve a given hostname by a canonical hostname.
|
public static String getLocalHostName()
public static String getLocalIpAddress()
public 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
UnknownHostException
public static int getPort(org.apache.thrift.transport.TNonblockingServerSocket thriftSocket)
getSocket(org.apache.thrift.transport.TNonblockingServerSocket)
, so reflection will be
used to get the port.public static ServerSocket getSocket(org.apache.thrift.transport.TNonblockingServerSocket thriftSocket)
RuntimeException
- if reflection calls failCopyright © 2015. All Rights Reserved.