• zookeeper Zookeeper


    这是ZooKeeper客户端库的主要类。使用一个ZooKeeper服务,应用程序必须首先实例化ZooKeeper类的对象。所有的迭代都将通过调用ZooKeeper类的方法来完成。除非另有说明,该类的方法是线程安全的。

    构造函数:

        public ZooKeeper(String connectString, int sessionTimeout, Watcher watcher)
            throws IOException
        {
            this(connectString, sessionTimeout, watcher, false);
        }
    

      

        public ZooKeeper(String connectString, int sessionTimeout, Watcher watcher,
                boolean canBeReadOnly)
            throws IOException{
            LOG.info("Initiating client connection, connectString=" + connectString
                    + " sessionTimeout=" + sessionTimeout + " watcher=" + watcher);
    
            watchManager.defaultWatcher = watcher;
    
            ConnectStringParser connectStringParser = new ConnectStringParser(
                    connectString);
            HostProvider hostProvider = new StaticHostProvider(
                    connectStringParser.getServerAddresses());
            cnxn = new ClientCnxn(connectStringParser.getChrootPath(),
                    hostProvider, sessionTimeout, this, watchManager,
                    getClientCnxnSocket(), canBeReadOnly);
            cnxn.start();
        }
    

      

        public ZooKeeper(String connectString, int sessionTimeout, Watcher watcher,
                long sessionId, byte[] sessionPasswd)
            throws IOException{
            this(connectString, sessionTimeout, watcher, sessionId, sessionPasswd, false);
        }
    

      

        public ZooKeeper(String connectString, int sessionTimeout, Watcher watcher,
                long sessionId, byte[] sessionPasswd, boolean canBeReadOnly)
            throws IOException{
            LOG.info("Initiating client connection, connectString=" + connectString
                    + " sessionTimeout=" + sessionTimeout
                    + " watcher=" + watcher
                    + " sessionId=" + Long.toHexString(sessionId)
                    + " sessionPasswd="
                    + (sessionPasswd == null ? "<null>" : "<hidden>"));
    
            watchManager.defaultWatcher = watcher;
    
            ConnectStringParser connectStringParser = new ConnectStringParser(
                    connectString);
            HostProvider hostProvider = new StaticHostProvider(
                    connectStringParser.getServerAddresses());
            cnxn = new ClientCnxn(connectStringParser.getChrootPath(),
                    hostProvider, sessionTimeout, this, watchManager,
                    getClientCnxnSocket(), sessionId, sessionPasswd, canBeReadOnly);
            cnxn.seenRwServerBefore = true; // since user has provided sessionId
            cnxn.start();
        }
    

      

  • 相关阅读:
    浅谈一致性Hash原理及应用
    学习sql中的排列组合,在园子里搜着看于是。。。
    SQL Server DAC——专用管理员连接
    通过phantomjs 进行页面截图
    《javascript算法--对象的比较》
    React-生命周期的相关介绍
    常用的谷歌插件
    webpack的externals的使用
    mac 10.12显示隐藏文件
    “文字”聚合、散出动画-转自奇舞团
  • 原文地址:https://www.cnblogs.com/shiguotao-com/p/9368781.html
Copyright © 2020-2023  润新知