/// <summary> /// new /// </summary> /// <param name="chrootPath"></param> /// <param name="connectionString">127.0.0.1:2181,10.0.51.14:2181</param> /// <param name="sessionTimeout"></param> /// <param name="defaultWatcher"></param> /// <exception cref="ArgumentNullException">connectionString is null or empty.</exception> public ZookClient(string chrootPath, string connectionString, TimeSpan sessionTimeout, IWatcher defaultWatcher = null) : base(new ZookProtocol(), 8192, 8192, 3000, 3000) { if (string.IsNullOrEmpty(connectionString)) { throw new ArgumentNullException("connectionString"); } if (!string.IsNullOrEmpty(chrootPath)) { Utils.PathUtils.ValidatePath(chrootPath); } this._chrootPath = chrootPath; this._sessionTimeout = sessionTimeout; this._watcherManager = new ZookWatcherManager(defaultWatcher); this._zkServerPool.SetOptions(this, connectionString); this.StartLoopPing(); }
/// <summary> /// new /// </summary> /// <param name="chrootPath"></param> /// <param name="connectionString">127.0.0.1:2181,10.0.51.14:2181</param> /// <param name="sessionTimeout"></param> /// <param name="defaultWatcher"></param> /// <exception cref="ArgumentNullException">connectionString is null or empty.</exception> public ZookClient(string chrootPath, string connectionString, TimeSpan sessionTimeout, IWatcher defaultWatcher = null) : base(new ZookProtocol(), 8192, 8192, 3000, 3000) { if (string.IsNullOrEmpty(connectionString)) { throw new ArgumentNullException("connectionString"); } if (!string.IsNullOrEmpty(chrootPath)) { Utils.PathUtils.ValidatePath(chrootPath); } this._serverlist = connectionString .Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries) .Select(c => new IPEndPoint(IPAddress.Parse(c.Substring(0, c.IndexOf(":"))), int.Parse(c.Substring(c.IndexOf(":") + 1)))) .ToArray(); this._chrootPath = chrootPath; this._sessionTimeout = sessionTimeout; this._watcherManager = new ZookWatcherManager(defaultWatcher); base.TryRegisterEndPoint("zk", this._serverlist, this.ConnectToZookeeper); this.StartPing(); }