/// <summary>
        /// 连接ZooKeeper
        /// </summary>
        private void Connect()
        {
            string host = _webApi.GetZooKeeperHost();

            _zooKeeper = new ZooKeeper(host, new TimeSpan(0, 0, 0, DisconfClientSettings.ZooKeeperSessionTimeout), this);
            LogManager.GetLogger().Info(string.Format("DisconfClient.ConnectionWatcher.Connect,host:{0},connected.", host));
        }
Exemple #2
0
        /// <summary>
        /// 获取一个监视管理器
        /// </summary>
        /// <param name="webApi">配置中心服务接口</param>
        /// <returns></returns>
        public static WatcherManager GetWatcherManager(IDisconfWebApi webApi)
        {
            if (webApi == null)
            {
                throw new ArgumentNullException("webApi");
            }
            string         host           = webApi.GetZooKeeperHost();
            string         rootNode       = webApi.GetZooKeeperRootNode();
            WatcherManager watcherManager = new WatcherManager();

            watcherManager.Init(host, rootNode);
            return(watcherManager);
        }