Class ClientCnxn


  • public class ClientCnxn
    extends Object
    This class manages the socket i/o for the client. ClientCnxn maintains a list of available servers to connect to and "transparently" switches servers it is connected to as needed.
    • Constructor Detail

      • ClientCnxn

        public ClientCnxn​(String chrootPath,
                          HostProvider hostProvider,
                          int sessionTimeout,
                          ZKClientConfig clientConfig,
                          Watcher defaultWatcher,
                          org.apache.zookeeper.ClientCnxnSocket clientCnxnSocket,
                          boolean canBeReadOnly)
                   throws IOException
        Creates a connection object. The actual network connect doesn't get established until needed. The start() instance method must be called subsequent to construction.
        Parameters:
        chrootPath - the chroot of this client. Should be removed from this Class in ZOOKEEPER-838
        hostProvider - the list of ZooKeeper servers to connect to
        sessionTimeout - the timeout for connections.
        clientConfig - the client configuration.
        defaultWatcher - default watcher for this connection
        clientCnxnSocket - the socket implementation used (e.g. NIO/Netty)
        canBeReadOnly - whether the connection is allowed to go to read-only mode in case of partitioning
        Throws:
        IOException
      • ClientCnxn

        public ClientCnxn​(String chrootPath,
                          HostProvider hostProvider,
                          int sessionTimeout,
                          ZKClientConfig clientConfig,
                          Watcher defaultWatcher,
                          org.apache.zookeeper.ClientCnxnSocket clientCnxnSocket,
                          long sessionId,
                          byte[] sessionPasswd,
                          boolean canBeReadOnly)
                   throws IOException
        Creates a connection object. The actual network connect doesn't get established until needed. The start() instance method must be called subsequent to construction.
        Parameters:
        chrootPath - the chroot of this client. Should be removed from this Class in ZOOKEEPER-838
        hostProvider - the list of ZooKeeper servers to connect to
        sessionTimeout - the timeout for connections.
        clientConfig - the client configuration.
        defaultWatcher - default watcher for this connection
        clientCnxnSocket - the socket implementation used (e.g. NIO/Netty)
        sessionId - session id if re-establishing session
        sessionPasswd - session passwd if re-establishing session
        canBeReadOnly - whether the connection is allowed to go to read-only mode in case of partitioning
        Throws:
        IOException - in cases of broken network