internal NamespaceImpl(CuratorFrameworkImpl client, String @namespace) { if ( @namespace != null ) { try { PathUtils.validatePath("/" + @namespace); } catch (ArgumentException) { throw new ArgumentException("Invalid namespace: " + @namespace); } } this.client = client; this.@namespace = @namespace; ensurePathNeeded = new AtomicBoolean(@namespace != null); }
public void testRetryStatic() { CuratorZookeeperClient client = new CuratorZookeeperClient(ZkDefaultHosts, DefaultSessionTimeout, DefaultConnectionTimeout, null, new RetryOneTime(1)); SessionFailRetryLoop retryLoop = client.newSessionFailRetryLoop(SessionFailRetryLoop.Mode.RETRY); retryLoop.start(); try { client.start(); AtomicBoolean secondWasDone = new AtomicBoolean(false); AtomicBoolean firstTime = new AtomicBoolean(true); SessionFailRetryLoop.callWithRetry ( client, SessionFailRetryLoop.Mode.RETRY, CallableUtils.FromFunc<object>(() => { RetryLoop.callWithRetry( client, CallableUtils.FromFunc<object>(() => { Task<Stat> existsTask; if ( firstTime.compareAndSet(true, false) ) { existsTask = client.getZooKeeper().existsAsync("/foo/bar", false); existsTask.Wait(); Assert.Null(existsTask.Result); KillSession.kill(client.getZooKeeper(), ZkDefaultHosts, DefaultSessionTimeout); client.getZooKeeper(); client.blockUntilConnectedOrTimedOut(); } existsTask = client.getZooKeeper().existsAsync("/foo/bar", false); existsTask.Wait(); Assert.Null(existsTask.Result); return null; } )); RetryLoop.callWithRetry ( client, CallableUtils.FromFunc<object>(() => { Assert.False(firstTime.get()); Task<Stat> existsTask = client.getZooKeeper().existsAsync("/foo/bar", false); existsTask.Wait(); Assert.Null(existsTask.Result); secondWasDone.set(true); return null; } )); return null; } )); Assert.True(secondWasDone.get()); } finally { retryLoop.Dispose(); CloseableUtils.closeQuietly(client); } }