Package org.apache.hadoop.hdfs.net
Interface Peer
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
BasicInetPeer,DomainPeer,EncryptedPeer,NioInetPeer
Represents a connection to a peer.
-
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.
-
Method Details
-
getInputStreamChannel
ReadableByteChannel getInputStreamChannel()- Returns:
- The input stream channel associated with this peer, or null if it has none.
-
setReadTimeout
Set the read timeout on this peer.- Parameters:
timeoutMs- The timeout in milliseconds.- Throws:
IOException
-
getReceiveBufferSize
- Returns:
- The receive buffer size.
- Throws:
IOException
-
getTcpNoDelay
- Returns:
- True if TCP_NODELAY is turned on.
- Throws:
IOException
-
setWriteTimeout
Set the write timeout on this peer. Note: this is not honored for BasicInetPeer. SeeBasicInetPeer.setWriteTimeout(int)for details.- Parameters:
timeoutMs- The timeout in milliseconds.- Throws:
IOException
-
isClosed
boolean isClosed()- Returns:
- true only if the peer is closed.
-
close
Close the peer. It's safe to re-close a Peer that is already closed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getRemoteAddressString
String getRemoteAddressString()- Returns:
- A string representing the remote end of our connection to the peer.
-
getLocalAddressString
String getLocalAddressString()- Returns:
- A string representing the local end of our connection to the peer.
-
getInputStream
- Returns:
- An InputStream associated with the Peer. This InputStream will be valid until you close this peer with Peer#close.
- Throws:
IOException
-
getOutputStream
- Returns:
- An OutputStream associated with the Peer. This OutputStream will be valid until you close this peer with Peer#close.
- Throws:
IOException
-
isLocal
boolean isLocal()- Returns:
- True if the peer resides on the same computer as we.
-
getDomainSocket
org.apache.hadoop.net.unix.DomainSocket getDomainSocket()- Returns:
- The DomainSocket associated with the current peer, or null if there is none.
-
hasSecureChannel
boolean hasSecureChannel()Return true if the channel is secure.- Returns:
- True if our channel to this peer is not susceptible to man-in-the-middle attacks.
-