Beispiel #1
0
        public void testBackgroundConnect()
        {
            int CONNECTION_TIMEOUT_MS = 4000;

            CuratorZookeeperClient client = new CuratorZookeeperClient(ZkDefaultHosts,
                                                                        10000,
                                                                        CONNECTION_TIMEOUT_MS,
                                                                        null,
                                                                        new RetryOneTime(1));
            try
            {
                Assert.False(client.isConnected());
                client.start();
                bool outerMustContinue = false;
                do
                {
                    for ( int i = 0; i < (CONNECTION_TIMEOUT_MS / 1000); ++i )
                    {
                        if ( client.isConnected() )
                        {
                            outerMustContinue = true;
                            break;
                        }
                        Thread.Sleep(CONNECTION_TIMEOUT_MS);
                    }
                    if (outerMustContinue)
                    {
                        continue;
                    }
                    Assert.Fail();
                } while ( false );
            }
            finally
            {
                client.Dispose();
            }
        }