private TestableZooKeeper createClient(CountdownWatcher watcher, string hp, int timeout) { watcher.reset(); var zk = new TestableZooKeeper(hp, timeout, watcher); if (!watcher.clientConnected.Wait(timeout)) { Assert.fail("Unable to connect to server"); } lock (this) { if (!allClientsSetup) { LOG.error("allClients never setup"); Assert.fail("allClients never setup"); } if (allClients != null) { allClients.AddLast(zk); } else { // test done - close the zk, not needed zk.close(); } } return(zk); }
protected virtual ZooKeeper CreateClient() { CountdownWatcher watcher = new CountdownWatcher(); return(new ZooKeeper("10.1.13.1:2181", /*"54.202.130.108:2181",*/ new TimeSpan(0, 0, 0, 20000), watcher)); // return new ZooKeeper("10.1.13.1:2181", new TimeSpan(0, 0, 0, 10000), watcher); }
public void testPing() { ZooKeeper zkIdle = null; ZooKeeper zkWatchCreator = null; try { CountdownWatcher watcher = new CountdownWatcher(); zkIdle = CreateClient(); zkWatchCreator = CreateClient(watcher); var node = Guid.NewGuid(); for (int i = 0; i < 10; i++) { zkWatchCreator.Create("/" + node + i, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.Persistent); } for (int i = 0; i < 10; i++) { zkIdle.Exists("/" + node + i, true); } for (int i = 0; i < 10; i++) { Thread.Sleep(1000); zkWatchCreator.Delete("/" + node + i, -1); } // The bug will manifest itself here because zkIdle will expire zkIdle.Exists("/0", false); } finally { if (zkIdle != null) { zkIdle.Dispose(); } if (zkWatchCreator != null) { zkWatchCreator.Dispose(); } } }
public void testPing() { ZooKeeper zkIdle = null; ZooKeeper zkWatchCreator = null; try { CountdownWatcher watcher = new CountdownWatcher(); zkIdle = createClient(watcher, 10000); zkWatchCreator = createClient(); for (int i = 0; i < 10; i++) { zkWatchCreator.create("/" + i, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); } for (int i = 0; i < 10; i++) { zkIdle.exists("/" + i, true); } for (int i = 0; i < 10; i++) { Thread.Sleep(1000); zkWatchCreator.delete("/" + i, -1); } // The bug will manifest itself here because zkIdle will expire zkIdle.exists("/0", false); } finally { if (zkIdle != null) { zkIdle.close(); } if (zkWatchCreator != null) { zkWatchCreator.close(); } } }
protected ZooKeeper CreateClientWithAddress(string address) { CountdownWatcher watcher = new CountdownWatcher(); return(new ZooKeeper(address, new TimeSpan(0, 0, 0, 10000), watcher)); }
protected virtual ZooKeeper CreateClient(string node) { CountdownWatcher watcher = new CountdownWatcher(); return(new ZooKeeper("127.0.0.1:2181" + node, new TimeSpan(0, 0, 0, 10000), watcher)); }
public void testPing() { ZooKeeper zkIdle = null; ZooKeeper zkWatchCreator = null; try { CountdownWatcher watcher = new CountdownWatcher(); zkIdle = CreateClient(); zkWatchCreator = CreateClient(watcher); var node = Guid.NewGuid(); for (int i = 0; i < 10; i++) { zkWatchCreator.Create("/" + node + i, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.Persistent); } for (int i = 0; i < 10; i++) { zkIdle.Exists("/" + node + i, true); } for (int i = 0; i < 10; i++) { Thread.Sleep(1000); zkWatchCreator.Delete("/" + node + i, -1); } // The bug will manifest itself here because zkIdle will expire zkIdle.Exists("/0", false); } finally { if (zkIdle != null) { zkIdle.Dispose(); } if (zkWatchCreator != null) { zkWatchCreator.Dispose(); } } }
protected TestableZooKeeper createClient(CountdownWatcher watcher) { return(createClient(watcher, hostPort + m_currentRoot, CONNECTION_TIMEOUT)); }
protected ZooKeeper createClient(CountdownWatcher watcher, int timeout) { return(createClient(watcher, hostPort + m_currentRoot, timeout)); }
protected virtual ZooKeeper CreateClient(TimeSpan sessionTimeout) { CountdownWatcher watcher = new CountdownWatcher(); return(new ZooKeeper("127.0.0.1:2181", sessionTimeout, watcher)); }
protected ZooKeeper CreateClientWithAddress(string address) { CountdownWatcher watcher = new CountdownWatcher(); return new ZooKeeper(address, new TimeSpan(0, 0, 0, 10000), watcher); }
protected virtual ZooKeeper CreateClient(string node) { CountdownWatcher watcher = new CountdownWatcher(); return new ZooKeeper("127.0.0.1:2181" + node, new TimeSpan(0, 0, 0, 10000), watcher); }