Package org.menagerie.latches.spi

Examples of org.menagerie.latches.spi.ZkSemaphore.acquire()


    @Test(timeout = 2000l)
    public void testAcquireMultiplePermitsBlocksUntilAvailableTwoThreads() throws Exception{
        final CountDownLatch latch = new CountDownLatch(1);
        final DistributedSemaphore semaphore = new ZkSemaphore(2,basePath,zkSessionManager);

        semaphore.acquire(2);
        assertEquals("Incorrect number of permits reported!",0,semaphore.availablePermits());
        Future<Void> errorFuture = testService.submit(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                semaphore.acquire(2);
View Full Code Here


        semaphore.acquire(2);
        assertEquals("Incorrect number of permits reported!",0,semaphore.availablePermits());
        Future<Void> errorFuture = testService.submit(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                semaphore.acquire(2);
                latch.countDown();
                return null;
            }
        });
View Full Code Here

    @Test(timeout = 2000l)
    public void testAcquireMultiplePermitsBlocksUntilAvailableTwoClients() throws Exception{
        final CountDownLatch latch = new CountDownLatch(1);
        final DistributedSemaphore semaphore = new ZkSemaphore(2,basePath,zkSessionManager);

        semaphore.acquire();
        semaphore.acquire();
        assertEquals("Incorrect number of permits reported!",0,semaphore.availablePermits());
        Future<Void> errorFuture = testService.submit(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
View Full Code Here

    public void testAcquireMultiplePermitsBlocksUntilAvailableTwoClients() throws Exception{
        final CountDownLatch latch = new CountDownLatch(1);
        final DistributedSemaphore semaphore = new ZkSemaphore(2,basePath,zkSessionManager);

        semaphore.acquire();
        semaphore.acquire();
        assertEquals("Incorrect number of permits reported!",0,semaphore.availablePermits());
        Future<Void> errorFuture = testService.submit(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                ZooKeeper zk = newZooKeeper();
View Full Code Here

            @Override
            public Void call() throws Exception {
                ZooKeeper zk = newZooKeeper();
                try {
                    DistributedSemaphore semaphore2 = new ZkSemaphore(2, basePath, new BaseZkSessionManager(zk));
                    semaphore2.acquire(2);
                    latch.countDown();
                } finally {
                    zk.close();
                }
                return null;
View Full Code Here

    @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

    @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

TOP
Copyright © 2018 www.massapi.com. 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.