Package com.hazelcast.core

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


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

        boolean result = semaphore.init(2);

        assertTrue(result);
        assertEquals(2, semaphore.availablePermits());
    }

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


        semaphore.init(2);

        boolean result = semaphore.init(4);

        assertFalse(result);
        assertEquals(2, semaphore.availablePermits());
    }


    private class AcquireThread extends Thread {
        ISemaphore semaphore;
View Full Code Here

    @Test
    public void testAvailableReducePermits_WhenZero() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
        semaphore.init(0);
        semaphore.reducePermits(1);
        assertEquals(0, semaphore.availablePermits());
    }

    @Test
    public void testTryAcquire_whenAvailable() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
View Full Code Here

        }.start();
        Thread.sleep(1000);
        semaphore.release(2);

        assertTrue(latch.await(5, TimeUnit.SECONDS));
        assertEquals(1, semaphore.availablePermits());
    }

    @Test
    public void tryAcquire_Threaded() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
View Full Code Here

            }
        }.start();

        semaphore.release(2);
        assertTrue(latch.await(5, TimeUnit.SECONDS));
        assertEquals(1, semaphore.availablePermits());
    }
}
View Full Code Here

    @Test
    public void testRelease() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
        semaphore.init(0);
        semaphore.release();
        assertEquals(1, semaphore.availablePermits());
    }

    @Test
    public void testdrainPermits() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
View Full Code Here

    @Test
    public void testAvailablePermits_AfterDrainPermits() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
        semaphore.init(10);
        semaphore.drainPermits();
        assertEquals(0, semaphore.availablePermits());
    }

    @Test
    public void testTryAcquire_whenDrainPermits() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
View Full Code Here

    @Test
    public void testAvailablePermits() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
        semaphore.init(10);
        assertEquals(10, semaphore.availablePermits());
    }

    @Test
    public void testAvailableReducePermits() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
View Full Code Here

    @Test
    public void testAvailableReducePermits() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
        semaphore.init(10);
        semaphore.reducePermits(5);
        assertEquals(5, semaphore.availablePermits());
    }

    @Test
    public void testAvailableReducePermits_WhenZero() throws Exception {
        final ISemaphore semaphore = client.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.