Пример #1
0
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        protected internal virtual TestableZooKeeper CreateClient(ClientBaseWithFixes.CountdownWatcher
                                                                  watcher, string hp, int timeout)
        {
            watcher.Reset();
            TestableZooKeeper zk = new TestableZooKeeper(hp, timeout, watcher);

            if (!watcher.clientConnected.Await(timeout, TimeUnit.Milliseconds))
            {
                NUnit.Framework.Assert.Fail("Unable to connect to server");
            }
            lock (this)
            {
                if (!allClientsSetup)
                {
                    Log.Error("allClients never setup");
                    NUnit.Framework.Assert.Fail("allClients never setup");
                }
                if (allClients != null)
                {
                    allClients.AddItem(zk);
                }
                else
                {
                    // test done - close the zk, not needed
                    zk.Close();
                }
            }
            watcher.InitializeWatchedClient(zk);
            return(zk);
        }