Example #1
0
        protected void WaitNodeExists(string path, bool expected = true)
        {
            var wait = new Action(
                () =>
            {
                var exists = ZooKeeperClient.Exists(path);
                exists.IsSuccessful.Should().Be(true);
                exists.Exists.Should().Be(expected);
            });

            wait.ShouldPassIn(DefaultTimeout);
        }
        public void Exists_should_add_watch_triggered_by_Created()
        {
            var path    = "/watch/new";
            var watcher = new TestWatcher();

            client.Exists(new ExistsRequest(path)
            {
                Watcher = watcher
            }).EnsureSuccess();
            client.Create(new CreateRequest(path, CreateMode.Persistent)).EnsureSuccess();
            watcher.ShouldBeTriggeredBy(NodeChangedEventType.Created, path);
        }
Example #3
0
        public void ZooKeeperClientCreatesANewPathAndDeletesIt()
        {
            var prodConfig = this.ZooKeeperBasedSyncProdConfig;

            using (IZooKeeperClient client = new ZooKeeperClient(
                       prodConfig.ZooKeeper.ZkConnect,
                       prodConfig.ZooKeeper.ZkSessionTimeoutMs,
                       ZooKeeperStringSerializer.Serializer))
            {
                client.Connect();
                string myPath = "/" + Guid.NewGuid();
                client.CreatePersistent(myPath, false);
                Assert.IsTrue(client.Exists(myPath));
                client.Delete(myPath);
                Assert.IsFalse(client.Exists(myPath));
            }
        }
Example #4
0
        public void ZooKeeperClientChecksIfPathExists()
        {
            var prodConfig = this.ZooKeeperBasedSyncProdConfig;

            using (IZooKeeperClient client = new ZooKeeperClient(
                       prodConfig.ZooKeeper.ZkConnect,
                       prodConfig.ZooKeeper.ZkSessionTimeoutMs,
                       ZooKeeperStringSerializer.Serializer))
            {
                client.Connect();
                Assert.IsTrue(client.Exists(ZooKeeperClient.DefaultBrokerTopicsPath, false));
            }
        }