Class NIOServerCnxn

  • All Implemented Interfaces:
    Watcher

    public class NIOServerCnxn
    extends ServerCnxn
    This class handles communication with clients using NIO. There is one per client, but only one thread doing the communication.
    • Field Detail

      • sk

        protected final java.nio.channels.SelectionKey sk
    • Constructor Detail

      • NIOServerCnxn

        public NIOServerCnxn​(ZooKeeperServer zk,
                             java.nio.channels.SocketChannel sock,
                             java.nio.channels.SelectionKey sk,
                             NIOServerCnxnFactory factory)
                      throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • sendCloseSession

        public void sendCloseSession()
      • sendBuffer

        public void sendBuffer​(java.nio.ByteBuffer bb)
      • internalSendBuffer

        protected void internalSendBuffer​(java.nio.ByteBuffer bb)
        This method implements the internals of sendBuffer. We have separated it from send buffer to be able to catch exceptions when testing.
        Parameters:
        bb - Buffer to send.
      • isSocketOpen

        protected boolean isSocketOpen()
        Only used in order to allow testing
      • getSocketAddress

        public java.net.InetAddress getSocketAddress()
        Description copied from class: ServerCnxn
        Wrapper method to return the socket address
        Specified by:
        getSocketAddress in class ServerCnxn
      • disableRecv

        public void disableRecv()
      • enableRecv

        public void enableRecv()
      • getSessionTimeout

        public int getSessionTimeout()
      • close

        public void close()
      • getSessionId

        public long getSessionId()
      • setSessionId

        public void setSessionId​(long sessionId)
      • setSessionTimeout

        public void setSessionTimeout​(int sessionTimeout)