Пример #1
0
        public virtual void TestSimple()
        {
            Timing           timing = new Timing();
            ChildReaper      reaper = null;
            CuratorFramework client = CuratorFrameworkFactory.NewClient(server.GetConnectString
                                                                            (), timing.Session(), timing.Connection(), new RetryOneTime(1));

            try
            {
                client.Start();
                for (int i = 0; i < 10; ++i)
                {
                    client.Create().CreatingParentsIfNeeded().ForPath("/test/" + Extensions.ToString
                                                                          (i));
                }
                reaper = new ChildReaper(client, "/test", Reaper.Mode.ReapUntilDelete, 1);
                reaper.Start();
                timing.ForWaiting().SleepABit();
                Stat stat = client.CheckExists().ForPath("/test");
                Assert.Equal(stat.GetNumChildren(), 0);
            }
            finally
            {
                CloseableUtils.CloseQuietly(reaper);
                CloseableUtils.CloseQuietly(client);
            }
        }
Пример #2
0
        public virtual void TestNamespace()
        {
            Timing           timing = new Timing();
            ChildReaper      reaper = null;
            CuratorFramework client = CuratorFrameworkFactory.Builder().ConnectString(server.
                                                                                      GetConnectString()).SessionTimeoutMs(timing.Session()).ConnectionTimeoutMs(timing
                                                                                                                                                                 .Connection()).RetryPolicy(new RetryOneTime(1)).Namespace("foo").Build();

            try
            {
                client.Start();
                for (int i = 0; i < 10; ++i)
                {
                    client.Create().CreatingParentsIfNeeded().ForPath("/test/" + Extensions.ToString
                                                                          (i));
                }
                reaper = new ChildReaper(client, "/test", Reaper.Mode.ReapUntilDelete, 1);
                reaper.Start();
                timing.ForWaiting().SleepABit();
                Stat stat = client.CheckExists().ForPath("/test");
                Assert.Equal(stat.GetNumChildren(), 0);
                stat = client.UsingNamespace(null).CheckExists().ForPath("/foo/test");
                NUnit.Framework.Assert.IsNotNull(stat);
                Assert.Equal(stat.GetNumChildren(), 0);
            }
            finally
            {
                CloseableUtils.CloseQuietly(reaper);
                CloseableUtils.CloseQuietly(client);
            }
        }