[Zookeeper学习笔记之7]Zookeeper源代码分析之Zookeeper.States

[Zookeeper学习笔记之七]Zookeeper源代码分析之Zookeeper.States
    public enum States {
        CONNECTING, //Zookeeper服务器不可用,客户端处于尝试链接状态
        ASSOCIATING, //???
        CONNECTED, //链接建立,可以与Zookeeper服务器正常通信
        CONNECTEDREADONLY, //处于只读状态的链接状态,只读模式可以在构造Zookeeper时指定
        CLOSED, //会话关闭,显式调用Zookeeper的close方法
        AUTH_FAILED, //建立链接时,认证失败
        NOT_CONNECTED; //链接断开状态
        
        //会话在两种状态下处于Alive状态,没有关闭,没有认证失败
        //CONNECTING,NOT_CONNECTED都出于Alive状态
        public boolean isAlive() {
            return this != CLOSED && this != AUTH_FAILED;
        }

        /**
         * Returns whether we are connected to a server (which
         * could possibly be read-only, if this client is allowed
         * to go to read-only mode)
         * */
        public boolean isConnected() {
            return this == CONNECTED || this == CONNECTEDREADONLY;
        }
    }