Пример #1
0
 /// <summary>
 /// Most operations done through this {@link org.I0Itec.zkclient.ZookeeperClient} are retried in cases like
 /// connection loss with the Zookeeper servers.During such failures, this
 /// <code>operationRetryTimeout</code> decides the maximum amount of time, in milli seconds, each
 /// operation is retried.A value lesser than 0 is considered as
 /// retry forever until a connection has been reestablished".
 /// </summary>
 /// <param name="zkConnection"> The Zookeeper servers</param>
 /// <param name="connectionTimeout"> The connection timeout in milli seconds</param>
 /// <param name="IZKSerializer"></param>
 /// <param name="operationRetryTimeout"> The Zookeeper data serializer</param>
 public ZKClient(IZKConnection zkConnection, TimeSpan connectionTimeout, IZKSerializer zkSerializer, TimeSpan operationRetryTimeout)
 {
     _connection            = zkConnection ?? throw new ArgumentNullException("Zookeeper connection is null!");
     _zkSerializer          = zkSerializer;
     _operationRetryTimeout = operationRetryTimeout;
     Connect(connectionTimeout, this);
 }
Пример #2
0
 /// <summary>
 /// Most operations done through this {@link org.I0Itec.zkclient.ZKClient} are retried in cases like
 /// connection loss with the Zookeeper servers.During such failures, this
 /// <code>operationRetryTimeout</code> decides the maximum amount of time, in milli seconds, each
 /// operation is retried.A value lesser than 0 is considered as
 /// retry forever until a connection has been reestablished".
 /// </summary>
 /// <param name="zkConnection"> The Zookeeper servers</param>
 /// <param name="connectionTimeout"> The connection timeout in milli seconds</param>
 /// <param name="IZKSerializer"></param>
 /// <param name="operationRetryTimeout"> The Zookeeper data serializer</param>
 public ZKClient(IZKConnection zkConnection, TimeSpan connectionTimeout, IZKSerializer zkSerializer, long operationRetryTimeout)
 {
     if (zkConnection == null)
     {
         throw new ArgumentNullException("Zookeeper connection is null!");
     }
     _connection   = zkConnection;
     _zkSerializer = zkSerializer;
     _operationRetryTimeoutInMillis = operationRetryTimeout;
     //_isZKSaslEnabled = IsZKSaslEnabled();
     Connect(connectionTimeout, this);
 }
Пример #3
0
        public ZooKeeperClient(IZKConnection zkConnection, TimeSpan connectionTimeout, TimeSpan retryTimeout)
        {
            _serialize         = new SerializeHelper();
            _zkConnection      = zkConnection;
            _stateListeners    = new ConcurrentHashSet <IZKStateListener>();
            _nodeListeners     = new ConcurrentDictionary <string, ConcurrentHashSet <IZKNodeListener> >();
            _childListeners    = new ConcurrentDictionary <string, ConcurrentHashSet <IZKChildNodeListener> >();
            _ephemeralNodels   = new ConcurrentDictionary <string, Node>();
            _retryTimeout      = retryTimeout;
            _connectionTimeout = connectionTimeout;

            this.Connect(connectionTimeout, this);
        }
Пример #4
0
        public void TestSequentials()
        {
            _connection = EstablishConnection();

            string sequentialPath  = _connection.Create("/a", new byte[0], CreateMode.EphemeralSequential);
            int    firstSequential = int.Parse(sequentialPath.Substring(2));

            Assert.True("/a" + ZKPathUtil.LeadingZeros(firstSequential++, 10) == sequentialPath);
            Assert.True("/a" + ZKPathUtil.LeadingZeros(firstSequential++, 10) == _connection.Create("/a", new byte[0], CreateMode.EphemeralSequential));
            Assert.True("/a" + ZKPathUtil.LeadingZeros(firstSequential++, 10) == _connection.Create("/a", new byte[0], CreateMode.EphemeralSequential));
            Assert.True("/b" + ZKPathUtil.LeadingZeros(firstSequential++, 10) == _connection.Create("/b", new byte[0], CreateMode.EphemeralSequential));
            Assert.True("/b" + ZKPathUtil.LeadingZeros(firstSequential++, 10) == _connection.Create("/b", new byte[0], CreateMode.EphemeralSequential));
            Assert.True("/a" + ZKPathUtil.LeadingZeros(firstSequential++, 10) == _connection.Create("/a", new byte[0], CreateMode.EphemeralSequential));
            _connection.Close();
            _connection = null;
        }
Пример #5
0
        public async Task TestSequentials()
        {
            _connection = EstablishConnection();

            string sequentialPath = await _connection.CreateAsync("/a", new byte[0], CreateMode.EPHEMERAL_SEQUENTIAL);

            int firstSequential = int.Parse(sequentialPath.Substring(2));

            Assert.True("/a" + ZKPathUtil.LeadingZeros(firstSequential++, 10) == sequentialPath);
            Assert.True("/a" + ZKPathUtil.LeadingZeros(firstSequential++, 10) ==
                        await _connection.CreateAsync("/a", new byte[0], CreateMode.EPHEMERAL_SEQUENTIAL));
            Assert.True("/a" + ZKPathUtil.LeadingZeros(firstSequential++, 10) ==
                        await _connection.CreateAsync("/a", new byte[0], CreateMode.EPHEMERAL_SEQUENTIAL));
            Assert.True("/b" + ZKPathUtil.LeadingZeros(firstSequential++, 10) ==
                        await _connection.CreateAsync("/b", new byte[0], CreateMode.EPHEMERAL_SEQUENTIAL));
            Assert.True("/b" + ZKPathUtil.LeadingZeros(firstSequential++, 10) ==
                        await _connection.CreateAsync("/b", new byte[0], CreateMode.EPHEMERAL_SEQUENTIAL));
            Assert.True("/a" + ZKPathUtil.LeadingZeros(firstSequential++, 10) ==
                        await _connection.CreateAsync("/a", new byte[0], CreateMode.EPHEMERAL_SEQUENTIAL));
            _connection.Close();
            _connection = null;
        }
Пример #6
0
 public ZKClient(IZKConnection zkConnection, TimeSpan connectionTimeout, IZKSerializer zkSerializer) : this(zkConnection, connectionTimeout, zkSerializer, TimeSpan.FromSeconds(-1))
 {
 }
Пример #7
0
 public ZKClient(IZKConnection connection, TimeSpan connectionTimeout) : this(connection, connectionTimeout, new SerializableSerializer())
 {
 }
Пример #8
0
 public ZKClient(IZKConnection connection) : this(connection, TimeSpan.FromMilliseconds(10000))
 {
 }
Пример #9
0
 public ZooKeeperClient(IZKConnection zkConnection) :
     this(zkConnection, new TimeSpan(0, 0, 0, 10), new TimeSpan(0, 0, 0, 10))
 {
 }
Пример #10
0
 public ZooKeeperClient(IZKConnection zkConnection, TimeSpan connectionTimeout) :
     this(zkConnection, connectionTimeout, new TimeSpan(0, 0, 0, 10))
 {
 }
Пример #11
0
 public ZKClient(IZKConnection zkConnection, TimeSpan connectionTimeout, IZKSerializer zkSerializer) : this(zkConnection, connectionTimeout, zkSerializer, -1)
 {
 }
Пример #12
0
 public ZKClient(IZKConnection connection) : this(connection, new TimeSpan(0, 0, 0, 0, int.MaxValue))
 {
 }