コード例 #1
0
        public void Should_locate_registered_ServiceBeacon_service_with_custom_path_escaper()
        {
            var replica = new ReplicaInfo("default", "vostok", "https://github.com/vostok");

            ZooKeeperClient.Create("/service-discovery/v2/ZGVmYXVsdA==", CreateMode.Persistent);

            using (var beacon = new ServiceBeacon(
                       ZooKeeperClient,
                       replica,
                       new ServiceBeaconSettings
            {
                IterationPeriod = 60.Seconds(),
                MinimumTimeBetweenIterations = 100.Milliseconds(),
                ZooKeeperNodesPathEscaper = new CustomPathEscaper()
            },
                       Log))
            {
                beacon.Start();
                WaitNodeExists("/service-discovery/v2/ZGVmYXVsdA==/dm9zdG9r/aHR0cHM6Ly9naXRodWIuY29tL3Zvc3Rvaw==");

                using (var locator = new ServiceLocator(
                           ZooKeeperClient,
                           new ServiceLocatorSettings
                {
                    ZooKeeperNodesPathEscaper = new CustomPathEscaper()
                },
                           Log))
                {
                    ShouldLocateImmediately(locator, replica.Environment, replica.Application, replica.Replica);
                }
            }
        }
コード例 #2
0
        private void CreateOrUpdate(string path, byte[] data, bool persistent = true)
        {
            var create = ZooKeeperClient.Create(path, persistent ? CreateMode.Persistent : CreateMode.Ephemeral, data);

            (create.Status == ZooKeeperStatus.Ok || create.Status == ZooKeeperStatus.NodeAlreadyExists).Should().BeTrue();
            if (create.Status == ZooKeeperStatus.NodeAlreadyExists)
            {
                ZooKeeperClient.SetData(path, data).IsSuccessful.Should().BeTrue();
            }
        }
コード例 #3
0
        public new void SetUp()
        {
            client = GetClient();

            for (var attempt = 0; attempt < 3; attempt++)
            {
                try
                {
                    client.Delete(new DeleteRequest("/watch")
                    {
                        DeleteChildrenIfNeeded = true
                    }).EnsureSuccess();
                    client.Create(new CreateRequest("/watch/a/b/c", CreateMode.Persistent)).EnsureSuccess();
                    client.Create(new CreateRequest("/watch/a/b/d", CreateMode.Persistent)).EnsureSuccess();
                    client.Create(new CreateRequest("/watch/a/e", CreateMode.Persistent)).EnsureSuccess();
                }
                catch (Exception e)
                {
                    Log.Error(e, "Failed to SetUp initial tree.");
                }
            }
        }
コード例 #4
0
 public new void SetUp()
 {
     client.Delete(new DeleteRequest("/watch")
     {
         DeleteChildrenIfNeeded = true
     });
     client.Create(new CreateRequest("/watch/a/b/c", CreateMode.Persistent)).EnsureSuccess();
     client.Create(new CreateRequest("/watch/a/b/d", CreateMode.Persistent)).EnsureSuccess();
     client.Create(new CreateRequest("/watch/a/e", CreateMode.Persistent)).EnsureSuccess();
 }
コード例 #5
0
        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);
        }