Package org.apache.hadoop.hdfs.net
Class NioInetPeer
java.lang.Object
org.apache.hadoop.hdfs.net.NioInetPeer
- All Implemented Interfaces:
Closeable,AutoCloseable,Peer
Represents a peer that we communicate with by using non-blocking I/O
on a Socket.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the peer.org.apache.hadoop.net.unix.DomainSocketintbooleanbooleanReturn true if the channel is secure.booleanisClosed()booleanisLocal()voidsetReadTimeout(int timeoutMs) Set the read timeout on this peer.voidsetWriteTimeout(int timeoutMs) Set the write timeout on this peer.toString()
-
Constructor Details
-
NioInetPeer
- Throws:
IOException
-
-
Method Details
-
getInputStreamChannel
- Specified by:
getInputStreamChannelin interfacePeer- Returns:
- The input stream channel associated with this peer, or null if it has none.
-
setReadTimeout
Description copied from interface:PeerSet the read timeout on this peer.- Specified by:
setReadTimeoutin interfacePeer- Parameters:
timeoutMs- The timeout in milliseconds.- Throws:
IOException
-
getReceiveBufferSize
- Specified by:
getReceiveBufferSizein interfacePeer- Returns:
- The receive buffer size.
- Throws:
IOException
-
getTcpNoDelay
- Specified by:
getTcpNoDelayin interfacePeer- Returns:
- True if TCP_NODELAY is turned on.
- Throws:
IOException
-
setWriteTimeout
Description copied from interface:PeerSet the write timeout on this peer. Note: this is not honored for BasicInetPeer. SeeBasicInetPeer.setWriteTimeout(int)for details.- Specified by:
setWriteTimeoutin interfacePeer- Parameters:
timeoutMs- The timeout in milliseconds.- Throws:
IOException
-
isClosed
public boolean isClosed() -
close
Description copied from interface:PeerClose the peer. It's safe to re-close a Peer that is already closed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfacePeer- Throws:
IOException
-
getRemoteAddressString
- Specified by:
getRemoteAddressStringin interfacePeer- Returns:
- A string representing the remote end of our connection to the peer.
-
getLocalAddressString
- Specified by:
getLocalAddressStringin interfacePeer- Returns:
- A string representing the local end of our connection to the peer.
-
getInputStream
- Specified by:
getInputStreamin interfacePeer- Returns:
- An InputStream associated with the Peer. This InputStream will be valid until you close this peer with Peer#close.
- Throws:
IOException
-
getOutputStream
- Specified by:
getOutputStreamin interfacePeer- Returns:
- An OutputStream associated with the Peer. This OutputStream will be valid until you close this peer with Peer#close.
- Throws:
IOException
-
isLocal
public boolean isLocal() -
toString
-
getDomainSocket
public org.apache.hadoop.net.unix.DomainSocket getDomainSocket()- Specified by:
getDomainSocketin interfacePeer- Returns:
- The DomainSocket associated with the current peer, or null if there is none.
-
hasSecureChannel
public boolean hasSecureChannel()Description copied from interface:PeerReturn true if the channel is secure.- Specified by:
hasSecureChannelin interfacePeer- Returns:
- True if our channel to this peer is not susceptible to man-in-the-middle attacks.
-