Package org.menagerie.latches.spi

Examples of org.menagerie.latches.spi.ZkSemaphore


        errorFuture.get();
    }

    @Test(timeout = 1000l)
    public void testReleaseMultiplePermits() throws Exception{
        DistributedSemaphore semaphore = new ZkSemaphore(2,basePath,zkSessionManager);

        semaphore.acquire();
        semaphore.acquire();
        assertEquals("Incorrect number of permits reported!",0,semaphore.availablePermits());

        semaphore.release(2);
        assertEquals("Incorrect number of permits reported",2,semaphore.availablePermits());
    }
View Full Code Here


        assertEquals("Incorrect number of permits reported",2,semaphore.availablePermits());
    }

    @Test(timeout = 1000l)
    public void testTryAcquire() throws Exception{
        DistributedSemaphore semaphore = new ZkSemaphore(2,basePath,zkSessionManager);
        assertTrue("Semaphore did not acquire!",semaphore.tryAcquire());
    }
View Full Code Here

    }

    @Test(timeout = 1000l)
    public void testTryAcquireTimesOut() throws Exception{
        final CountDownLatch latch = new CountDownLatch(1);
        final DistributedSemaphore semaphore = new ZkSemaphore(1,basePath,zkSessionManager);
        assertTrue("Semaphore did not acquire!",semaphore.tryAcquire());

        Future<Void> errorFuture = testService.submit(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                semaphore.tryAcquire(500, TimeUnit.MILLISECONDS);
                latch.countDown();
                return null;
            }
        });
View Full Code Here

TOP

Related Classes of org.menagerie.latches.spi.ZkSemaphore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.