|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.hadoop.net.NetUtils
public class NetUtils
| Constructor Summary | |
|---|---|
NetUtils()
|
|
| Method Summary | |
|---|---|
static void |
addStaticResolution(java.lang.String host,
java.lang.String resolvedName)
Adds a static resolution for host. |
static void |
connect(java.net.Socket socket,
java.net.SocketAddress endpoint,
int timeout)
This is a drop-in replacement for Socket.connect(SocketAddress, int). |
static java.net.InetSocketAddress |
createSocketAddr(java.lang.String target)
Util method to build socket addr from either: |
static java.net.InetSocketAddress |
createSocketAddr(java.lang.String target,
int defaultPort)
Util method to build socket addr from either: |
static java.util.List<java.lang.String[]> |
getAllStaticResolutions()
This is used to get all the resolutions that were added using addStaticResolution(String, String). |
static java.net.InetSocketAddress |
getConnectAddress(Server server)
Returns InetSocketAddress that a client can use to connect to the server. |
static javax.net.SocketFactory |
getDefaultSocketFactory(Configuration conf)
Get the default socket factory as specified by the configuration parameter hadoop.rpc.socket.factory.default |
static java.io.InputStream |
getInputStream(java.net.Socket socket)
Same as getInputStream(socket, socket.getSoTimeout()). From documentation for getInputStream(Socket, long):Returns InputStream for the socket. |
static java.io.InputStream |
getInputStream(java.net.Socket socket,
long timeout)
Returns InputStream for the socket. |
static java.io.OutputStream |
getOutputStream(java.net.Socket socket)
Same as getOutputStream(socket, 0). |
static java.io.OutputStream |
getOutputStream(java.net.Socket socket,
long timeout)
Returns OutputStream for the socket. |
static java.lang.String |
getServerAddress(Configuration conf,
java.lang.String oldBindAddressName,
java.lang.String oldPortName,
java.lang.String newBindAddressName)
Deprecated. |
static javax.net.SocketFactory |
getSocketFactory(Configuration conf,
java.lang.Class<?> clazz)
Get the socket factory for the given class according to its configuration parameter hadoop.rpc.socket.factory.class.<ClassName>. |
static javax.net.SocketFactory |
getSocketFactoryFromProperty(Configuration conf,
java.lang.String propValue)
Get the socket factory corresponding to the given proxy URI. |
static java.lang.String |
getStaticResolution(java.lang.String host)
Retrieves the resolved name for the passed host. |
static java.lang.String |
normalizeHostName(java.lang.String name)
Given a string representation of a host, return its ip address in textual presentation. |
static java.util.List<java.lang.String> |
normalizeHostNames(java.util.Collection<java.lang.String> names)
Given a collection of string representation of hosts, return a list of corresponding IP addresses in the textual representation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NetUtils()
| Method Detail |
|---|
public static javax.net.SocketFactory getSocketFactory(Configuration conf,
java.lang.Class<?> clazz)
conf - the configurationclazz - the class (usually a VersionedProtocol)
public static javax.net.SocketFactory getDefaultSocketFactory(Configuration conf)
conf - the configuration
public static javax.net.SocketFactory getSocketFactoryFromProperty(Configuration conf,
java.lang.String propValue)
propValue - the property which is the class name of the
SocketFactory to instantiate; assumed non null and non empty.
public static java.net.InetSocketAddress createSocketAddr(java.lang.String target)
public static java.net.InetSocketAddress createSocketAddr(java.lang.String target,
int defaultPort)
@Deprecated
public static java.lang.String getServerAddress(Configuration conf,
java.lang.String oldBindAddressName,
java.lang.String oldPortName,
java.lang.String newBindAddressName)
conf - the configuration to checkoldBindAddressName - the old address attribute nameoldPortName - the old port attribute namenewBindAddressName - the new combined name
public static void addStaticResolution(java.lang.String host,
java.lang.String resolvedName)
getStaticResolution(String) can be used to query for
the actual hostname.
host - resolvedName - public static java.lang.String getStaticResolution(java.lang.String host)
addStaticResolution(String, String)
host -
public static java.util.List<java.lang.String[]> getAllStaticResolutions()
addStaticResolution(String, String). The return
value is a List each element of which contains an array of String
of the form String[0]=hostname, String[1]=resolved-hostname
public static java.net.InetSocketAddress getConnectAddress(Server server)
server -
public static java.io.InputStream getInputStream(java.net.Socket socket)
throws java.io.IOException
getInputStream(Socket, long):SocketInputStream with the given timeout. If the socket does not
have a channel, Socket.getInputStream() is returned. In the later
case, the timeout argument is ignored and the timeout set with
Socket.setSoTimeout(int) applies for reads.NetUtils(),
must use this interface instead of Socket.getInputStream().
socket -
java.io.IOExceptiongetInputStream(Socket, long)
public static java.io.InputStream getInputStream(java.net.Socket socket,
long timeout)
throws java.io.IOException
SocketInputStream with the given timeout. If the socket does not
have a channel, Socket.getInputStream() is returned. In the later
case, the timeout argument is ignored and the timeout set with
Socket.setSoTimeout(int) applies for reads.NetUtils(),
must use this interface instead of Socket.getInputStream().
socket - timeout - timeout in milliseconds. This may not always apply. zero
for waiting as long as necessary.
java.io.IOExceptionSocket.getChannel()
public static java.io.OutputStream getOutputStream(java.net.Socket socket)
throws java.io.IOException
getOutputStream(Socket, long) : SocketOutputStream with the given timeout. If the socket does not
have a channel, Socket.getOutputStream() is returned. In the later
case, the timeout argument is ignored and the write will wait until
data is available.NetUtils(),
must use this interface instead of Socket.getOutputStream().
socket -
java.io.IOExceptiongetOutputStream(Socket, long)
public static java.io.OutputStream getOutputStream(java.net.Socket socket,
long timeout)
throws java.io.IOException
SocketOutputStream with the given timeout. If the socket does not
have a channel, Socket.getOutputStream() is returned. In the later
case, the timeout argument is ignored and the write will wait until
data is available.NetUtils(),
must use this interface instead of Socket.getOutputStream().
socket - timeout - timeout in milliseconds. This may not always apply. zero
for waiting as long as necessary.
java.io.IOExceptionSocket.getChannel()
public static void connect(java.net.Socket socket,
java.net.SocketAddress endpoint,
int timeout)
throws java.io.IOException
Socket.connect(SocketAddress, int).
In the case of normal sockets that don't have associated channels, this
just invokes socket.connect(endpoint, timeout). If
socket.getChannel() returns a non-null channel,
connect is implemented using Hadoop's selectors. This is done mainly
to avoid Sun's connect implementation from creating thread-local
selectors, since Hadoop does not have control on when these are closed
and could end up taking all the available file descriptors.
socket - endpoint - timeout - - timeout in milliseconds
java.io.IOExceptionSocket.connect(java.net.SocketAddress, int)public static java.lang.String normalizeHostName(java.lang.String name)
name - a string representation of a host:
either a textual representation its IP address or its host name
public static java.util.List<java.lang.String> normalizeHostNames(java.util.Collection<java.lang.String> names)
names - a collection of string representations of hosts
normalizeHostName(String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||