/// <summary> /// Connects to ZooKeeper server /// </summary> /// <param name="watcher"> /// The watcher to be installed in ZooKeeper. /// </param> public void Connect(IWatcher watcher) { if (this.disposed) { throw new ObjectDisposedException(this.GetType().Name); } lock (this.syncLock) { if (this._zkclient != null) { throw new InvalidOperationException("ZooKeeper client has already been started"); } try { Logger.InfoFormat("Starting ZK client .. with connect handler.. {0}...", watcher.ToString()); this._zkclient = new ZooKeeper(this.Servers, new TimeSpan(0, 0, 0, 0, this.SessionTimeout), watcher);//new ZkClientState(this.Servers, new TimeSpan(0, 0, 0, 0, this.SessionTimeout), watcher); Logger.InfoFormat("Finish start ZK client .. with connect handler.. {0}...", watcher.ToString()); } catch (IOException exc) { throw new ZooKeeperException("Unable to connect to " + this.Servers, exc); } } }
/// <summary> /// Connects to ZooKeeper server /// </summary> /// <param name="watcher"> /// The watcher to be installed in ZooKeeper. /// </param> public void Connect(IWatcher watcher) { if (disposed) { throw new ObjectDisposedException(GetType().Name); } lock (syncLock) { if (_zkclient != null) { throw new InvalidOperationException("ZooKeeper client has already been started"); } try { Logger.InfoFormat("Starting ZK client .. with connect handler.. {0}...", watcher.ToString()); _zkclient = new ZooKeeper(Servers, new TimeSpan(0, 0, 0, 0, SessionTimeout), watcher); //new ZkClientState(this.Servers, new TimeSpan(0, 0, 0, 0, this.SessionTimeout), watcher); Logger.InfoFormat("Finish start ZK client .. with connect handler.. {0}...", watcher.ToString()); } catch (IOException exc) { throw new ZooKeeperException("Unable to connect to " + Servers, exc); } } }