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.
    • Constructor Detail

      • NIOServerCnxn

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

      • sendCloseSession

        public void sendCloseSession()
      • sendBuffer

        public void sendBuffer​(java.nio.ByteBuffer bb)
        sendBuffer pushes a byte buffer onto the outgoing buffer queue for asynchronous writes.
      • isSelectable

        public boolean isSelectable()
      • disableSelectable

        public void disableSelectable()
      • enableSelectable

        public void enableSelectable()
      • isSocketOpen

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

        protected void incrOutstandingRequests​(org.apache.zookeeper.proto.RequestHeader h)
        Overrides:
        incrOutstandingRequests in class ServerCnxn
      • disableRecv

        public void disableRecv()
      • enableRecv

        public void enableRecv()
      • getSessionTimeout

        public int getSessionTimeout()
      • toString

        public java.lang.String toString()
        Used by "dump" 4-letter command to list all connection in cnxnExpiryMap
        Overrides:
        toString in class ServerCnxn
        See Also:
        for brief stats
      • close

        public void close()
        Close the cnxn and remove it from the factory cnxns list.
      • closeSock

        public static void closeSock​(java.nio.channels.SocketChannel sock)
        Close resources associated with a sock.
      • sendResponse

        public void sendResponse​(org.apache.zookeeper.proto.ReplyHeader h,
                                 org.apache.jute.Record r,
                                 java.lang.String tag)
        Overrides:
        sendResponse in class ServerCnxn
      • setSessionId

        public void setSessionId​(long sessionId)
      • setSessionTimeout

        public void setSessionTimeout​(int sessionTimeout)
      • getSocketAddress

        public java.net.InetAddress getSocketAddress()