@Test public void testSimple2() throws Exception { final int MAX_LEASES = 3; Timing timing = new Timing(); List<Lease> leases = Lists.newArrayList(); CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); client.start(); try { for ( int i = 0; i < MAX_LEASES; ++i ) { InterProcessSemaphoreV2 semaphore = new InterProcessSemaphoreV2(client, "/test", MAX_LEASES); Lease lease = semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS); Assert.assertNotNull(lease); leases.add(lease); } InterProcessSemaphoreV2 semaphore = new InterProcessSemaphoreV2(client, "/test", MAX_LEASES); Lease lease = semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS); Assert.assertNull(lease); leases.remove(0).close(); Assert.assertNotNull(semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS)); } finally { for ( Lease l : leases ) { CloseableUtils.closeQuietly(l); } TestCleanState.closeAndTestClean(client); } }
public Lease acquire() throws Exception { String path = internals.attemptLock(-1, null, null); return makeLease(path); }
InterProcessSemaphore { public Lease acquire() throws Exception { String path = internals.attemptLock(-1, null, null); return makeLease(path); } }
InterProcessSemaphore { public Lease acquire() throws Exception { String path = internals.attemptLock(-1, null, null); return makeLease(path); } InterProcessSemaphore(CuratorFramework client, String path, int maxLeases);  InterProcessSemaphore(CuratorFramework client, String path, SharedCountReader count); private  InterProcessSemaphore(CuratorFramework client, String path, int maxLeases, SharedCountReader count); }
InterProcessSemaphore { public Lease acquire() throws Exception { String path = internals.attemptLock(-1, null, null); return makeLease(path); } InterProcessSemaphore(CuratorFramework client, String path, int maxLeases);  InterProcessSemaphore(CuratorFramework client, String path, SharedCountReader count); private  InterProcessSemaphore(CuratorFramework client, String path, int maxLeases, SharedCountReader count); void returnAll(Collection<Lease> leases); void returnLease(Lease lease); Lease acquire(); Collection<Lease> acquire(int qty); Lease acquire(long time, TimeUnit unit); Collection<Lease> acquire(int qty, long time, TimeUnit unit); }
InterProcessSemaphore { public Lease acquire() throws Exception { String path = internals.attemptLock(-1, null, null); return makeLease(path); } InterProcessSemaphore(CuratorFramework client, String path, int maxLeases);  InterProcessSemaphore(CuratorFramework client, String path, SharedCountReader count); private  InterProcessSemaphore(CuratorFramework client, String path, int maxLeases, SharedCountReader count); void returnAll(Collection<Lease> leases); void returnLease(Lease lease); Lease acquire(); Collection<Lease> acquire(int qty); Lease acquire(long time, TimeUnit unit); Collection<Lease> acquire(int qty, long time, TimeUnit unit);  }