org.apache.hadoop.hdfs.net

## Class NioInetPeer

- java.lang.Object
- - org.apache.hadoop.hdfs.net.NioInetPeer

- All Implemented Interfaces:
    Closeable, AutoCloseable, org.apache.hadoop.hdfs.net.Peer

      public class NioInetPeer
      extends Object
      implements org.apache.hadoop.hdfs.net.Peer

  Represents a peer that we communicate with by using non-blocking I/O on a Socket.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `NioInetPeer(Socket socket)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Close the peer.
    `org.apache.hadoop.net.unix.DomainSocket` | `getDomainSocket()`
    `InputStream` | `getInputStream()`
    `ReadableByteChannel` | `getInputStreamChannel()`
    `String` | `getLocalAddressString()`
    `OutputStream` | `getOutputStream()`
    `int` | `getReceiveBufferSize()`
    `String` | `getRemoteAddressString()`
    `boolean` | `getTcpNoDelay()`
    `boolean` | `hasSecureChannel()` Return true if the channel is secure.
    `boolean` | `isClosed()`
    `boolean` | `isLocal()`
    `void` | `setReadTimeout(int timeoutMs)` Set the read timeout on this peer.
    `void` | `setWriteTimeout(int timeoutMs)` Set the write timeout on this peer.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### NioInetPeer

          public NioInetPeer(Socket socket)
                      throws IOException

      Throws:
        `IOException`

  - ### Method Detail

    - #### getInputStreamChannel

          public ReadableByteChannel getInputStreamChannel()

      Specified by:
        `getInputStreamChannel` in interface `org.apache.hadoop.hdfs.net.Peer`
      Returns:
        The input stream channel associated with this peer, or null if it has none.

    - #### setReadTimeout

          public void setReadTimeout(int timeoutMs)
                              throws IOException

      Description copied from interface: `org.apache.hadoop.hdfs.net.Peer`
      Set the read timeout on this peer.
      Specified by:
        `setReadTimeout` in interface `org.apache.hadoop.hdfs.net.Peer`
      Parameters:
        `timeoutMs` - The timeout in milliseconds.
      Throws:
        `IOException`

    - #### getReceiveBufferSize

          public int getReceiveBufferSize()
                                   throws IOException

      Specified by:
        `getReceiveBufferSize` in interface `org.apache.hadoop.hdfs.net.Peer`
      Returns:
        The receive buffer size.
      Throws:
        `IOException`

    - #### getTcpNoDelay

          public boolean getTcpNoDelay()
                                throws IOException

      Specified by:
        `getTcpNoDelay` in interface `org.apache.hadoop.hdfs.net.Peer`
      Returns:
        True if TCP_NODELAY is turned on.
      Throws:
        `IOException`

    - #### setWriteTimeout

          public void setWriteTimeout(int timeoutMs)
                               throws IOException

      Description copied from interface: `org.apache.hadoop.hdfs.net.Peer`
      Set the write timeout on this peer. Note: this is not honored for BasicInetPeer. See `BasicInetPeer.setWriteTimeout(int)` for details.
      Specified by:
        `setWriteTimeout` in interface `org.apache.hadoop.hdfs.net.Peer`
      Parameters:
        `timeoutMs` - The timeout in milliseconds.
      Throws:
        `IOException`

    - #### isClosed

          public boolean isClosed()

      Specified by:
        `isClosed` in interface `org.apache.hadoop.hdfs.net.Peer`
      Returns:
        true only if the peer is closed.

    - #### close

          public void close()
                     throws IOException

      Description copied from interface: `org.apache.hadoop.hdfs.net.Peer`
      Close the peer. It's safe to re-close a Peer that is already closed.
      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in interface `org.apache.hadoop.hdfs.net.Peer`
      Throws:
        `IOException`

    - #### getRemoteAddressString

          public String getRemoteAddressString()

      Specified by:
        `getRemoteAddressString` in interface `org.apache.hadoop.hdfs.net.Peer`
      Returns:
        A string representing the remote end of our connection to the peer.

    - #### getLocalAddressString

          public String getLocalAddressString()

      Specified by:
        `getLocalAddressString` in interface `org.apache.hadoop.hdfs.net.Peer`
      Returns:
        A string representing the local end of our connection to the peer.

    - #### getInputStream

          public InputStream getInputStream()
                                     throws IOException

      Specified by:
        `getInputStream` in interface `org.apache.hadoop.hdfs.net.Peer`
      Returns:
        An InputStream associated with the Peer. This InputStream will be valid until you close this peer with Peer#close.
      Throws:
        `IOException`

    - #### getOutputStream

          public OutputStream getOutputStream()
                                       throws IOException

      Specified by:
        `getOutputStream` in interface `org.apache.hadoop.hdfs.net.Peer`
      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()

      Specified by:
        `isLocal` in interface `org.apache.hadoop.hdfs.net.Peer`
      Returns:
        True if the peer resides on the same computer as we.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### getDomainSocket

          public org.apache.hadoop.net.unix.DomainSocket getDomainSocket()

      Specified by:
        `getDomainSocket` in interface `org.apache.hadoop.hdfs.net.Peer`
      Returns:
        The DomainSocket associated with the current peer, or null if there is none.

    - #### hasSecureChannel

          public boolean hasSecureChannel()

      Description copied from interface: `org.apache.hadoop.hdfs.net.Peer`
      Return true if the channel is secure.
      Specified by:
        `hasSecureChannel` in interface `org.apache.hadoop.hdfs.net.Peer`
      Returns:
        True if our channel to this peer is not susceptible to man-in-the-middle attacks.

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.