Interface Peer

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
BasicInetPeer, DomainPeer, EncryptedPeer, NioInetPeer

@Private public interface Peer extends Closeable
Represents a connection to a peer.
  • Method Details

    • getInputStreamChannel

      ReadableByteChannel getInputStreamChannel()
      Returns:
      The input stream channel associated with this peer, or null if it has none.
    • setReadTimeout

      void setReadTimeout(int timeoutMs) throws IOException
      Set the read timeout on this peer.
      Parameters:
      timeoutMs - The timeout in milliseconds.
      Throws:
      IOException
    • getReceiveBufferSize

      int getReceiveBufferSize() throws IOException
      Returns:
      The receive buffer size.
      Throws:
      IOException
    • getTcpNoDelay

      boolean getTcpNoDelay() throws IOException
      Returns:
      True if TCP_NODELAY is turned on.
      Throws:
      IOException
    • setWriteTimeout

      void setWriteTimeout(int timeoutMs) throws IOException
      Set the write timeout on this peer. Note: this is not honored for BasicInetPeer. See BasicInetPeer.setWriteTimeout(int) for details.
      Parameters:
      timeoutMs - The timeout in milliseconds.
      Throws:
      IOException
    • isClosed

      boolean isClosed()
      Returns:
      true only if the peer is closed.
    • close

      void close() throws IOException
      Close the peer. It's safe to re-close a Peer that is already closed.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      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

      InputStream getInputStream() throws IOException
      Returns:
      An InputStream associated with the Peer. This InputStream will be valid until you close this peer with Peer#close.
      Throws:
      IOException
    • getOutputStream

      OutputStream getOutputStream() throws IOException
      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.