コード例 #1
1
 public WatcherAnonymousInnerClassHelper(CuratorZookeeperClient outerInstance, CountDownLatch latch)
 {
     this.outerInstance = outerInstance;
     this.latch = latch;
 }
コード例 #2
0
ファイル: TestRetryLoop.cs プロジェクト: shayhatsor/curator
        //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
        //ORIGINAL LINE: @Test public void testRetryLoop() throws Exception
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testRetryLoop()
        {
            CuratorZookeeperClient client = new CuratorZookeeperClient(server.getConnectString(), 10000, 10000, null, new RetryOneTime(1));
            client.start();
            try
            {
                int loopCount = 0;
                RetryLoop retryLoop = client.newRetryLoop();
                while (retryLoop.shouldContinue())
                {
                    if (++loopCount > 2)
                    {
                        Assert.fail();
                        break;
                    }

                    try
                    {
                        client.getZooKeeper().create("/test", new sbyte[]{1,2,3}, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
                        retryLoop.markComplete();
                    }
                    catch (Exception e)
                    {
                        retryLoop.takeException(e);
                    }
                }

                Assert.assertTrue(loopCount > 0);
            }
            finally
            {
                client.close();
            }
        }
コード例 #3
0
ファイル: TestRetryLoop.cs プロジェクト: shayhatsor/curator
        //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
        //ORIGINAL LINE: @Test public void testRetryLoopWithFailure() throws Exception
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testRetryLoopWithFailure()
        {
            CuratorZookeeperClient client = new CuratorZookeeperClient(server.getConnectString(), 5000, 5000, null, new RetryOneTime(1));
            client.start();
            try
            {
                int loopCount = 0;
                RetryLoop retryLoop = client.newRetryLoop();
                while (retryLoop.shouldContinue())
                {
                    ++loopCount;
                    switch (loopCount)
                    {
                        case 1:
                        {
                            server.stop();
                            break;
                        }

                        case 2:
                        {
                            server.restart();
                            break;
                        }

                        case 3:
                        case 4:
                        {
                            // ignore
                            break;
                        }

                        default:
                        {
                            Assert.fail();
                            goto outerBreak;
                        }
                    }

                    try
                    {
                        client.blockUntilConnectedOrTimedOut();
                        client.getZooKeeper().create("/test", new sbyte[]{1,2,3}, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
                        retryLoop.markComplete();
                    }
                    catch (Exception e)
                    {
                        retryLoop.takeException(e);
                    }
                    outerContinue:;
                }
                outerBreak:

                Assert.assertTrue(loopCount >= 2);
            }
            finally
            {
                client.close();
            }
        }