Examples of availablePermits()


Examples of com.hazelcast.core.ISemaphore.availablePermits()

        assertEquals(10, s.availablePermits());

        getClient().send(new InitRequest(name, 20));
        result = (Boolean) getClient().receive();
        assertFalse(result);
        assertEquals(10, s.availablePermits());
    }

    @Test
    public void testReduce() throws Exception {
        ISemaphore s = getInstance().getSemaphore(name);
View Full Code Here

Examples of com.hazelcast.core.ISemaphore.availablePermits()

        assertTrue(s.init(10));

        getClient().send(new ReduceRequest(name, 4));
        boolean result = (Boolean) getClient().receive();
        assertTrue(result);
        assertEquals(6, s.availablePermits());
    }

    @Test
    public void testRelease() throws Exception {
        ISemaphore s = getInstance().getSemaphore(name);
View Full Code Here

Examples of com.hazelcast.core.ISemaphore.availablePermits()

        assertTrue(s.init(10));

        getClient().send(new ReleaseRequest(name, 4));
        boolean result = (Boolean) getClient().receive();
        assertTrue(result);
        assertEquals(14, s.availablePermits());
    }
}
View Full Code Here

Examples of com.hazelcast.core.ISemaphore.availablePermits()

        final ISemaphore semaphore = hz.getSemaphore(randomString());

        int numberOfPermits = 20;
        assertTrue(semaphore.init(numberOfPermits));
        for (int i = 0; i < numberOfPermits; i++) {
            assertEquals(numberOfPermits - i, semaphore.availablePermits());
            semaphore.acquire();
        }

        assertEquals(semaphore.availablePermits(), 0);
    }
View Full Code Here

Examples of com.hazelcast.core.ISemaphore.availablePermits()

        for (int i = 0; i < numberOfPermits; i++) {
            assertEquals(numberOfPermits - i, semaphore.availablePermits());
            semaphore.acquire();
        }

        assertEquals(semaphore.availablePermits(), 0);
    }

    @Test(timeout = 30000)
    public void testAcquire_whenNoPermits() throws InterruptedException {
        final ISemaphore semaphore = hz.getSemaphore(randomString());
View Full Code Here

Examples of com.hazelcast.core.ISemaphore.availablePermits()

        acquireThread.start();
        assertTrueAllTheTime(new AssertTask() {
            @Override
            public void run() throws Exception {
                assertTrue(acquireThread.isAlive());
                assertEquals(0, semaphore.availablePermits());
            }
        }, 5);
    }

    @Test(timeout = 30000)
View Full Code Here

Examples of com.hazelcast.core.ISemaphore.availablePermits()

        final ISemaphore semaphore = hz.getSemaphore(randomString());
        AcquireThread thread = new AcquireThread(semaphore);
        thread.start();

        semaphore.destroy();
        assertEquals(0, semaphore.availablePermits());
    }

    @Test(expected = IllegalStateException.class, timeout = 30000)
    public void testAcquire_whenInstanceShutdown() throws InterruptedException {
        final ISemaphore semaphore = hz.getSemaphore(randomString());
View Full Code Here

Examples of com.hazelcast.core.ISemaphore.availablePermits()

    public void testRelease() {
        final ISemaphore semaphore = hz.getSemaphore(randomString());

        int numberOfPermits = 20;
        for (int i = 0; i < numberOfPermits; i++) {
            assertEquals(i, semaphore.availablePermits());
            semaphore.release();
        }

        assertEquals(semaphore.availablePermits(), numberOfPermits);
    }
View Full Code Here

Examples of com.hazelcast.core.ISemaphore.availablePermits()

        for (int i = 0; i < numberOfPermits; i++) {
            assertEquals(i, semaphore.availablePermits());
            semaphore.release();
        }

        assertEquals(semaphore.availablePermits(), numberOfPermits);
    }

    @Test(timeout = 30000)
    public void testRelease_whenArgumentNegative() {
        final ISemaphore semaphore = hz.getSemaphore(randomString());
View Full Code Here

Examples of com.hazelcast.core.ISemaphore.availablePermits()

        try {
            semaphore.release(-5);
            fail();
        } catch (IllegalArgumentException expected) {
        }
        assertEquals(0, semaphore.availablePermits());
    }

    @Test(timeout = 30000)
    public void testRelease_whenBlockedAcquireThread() throws InterruptedException {
        final ISemaphore semaphore = hz.getSemaphore(randomString());
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.