Examples of availablePermits()


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

        for (int i = 0; i < k; i++) {
            int rand = (int) (Math.random() * 5) + 1;

            semaphore.acquire(rand);
            initialPermits -= rand;
            assertEquals(initialPermits, semaphore.availablePermits());
            semaphore.release(rand);
            initialPermits += rand;
            assertEquals(initialPermits, semaphore.availablePermits());

            instances[i].shutdown();
View Full Code Here

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

            semaphore.acquire(rand);
            initialPermits -= rand;
            assertEquals(initialPermits, semaphore.availablePermits());
            semaphore.release(rand);
            initialPermits += rand;
            assertEquals(initialPermits, semaphore.availablePermits());

            instances[i].shutdown();

            semaphore.acquire(rand);
            initialPermits -= rand;
View Full Code Here

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

            instances[i].shutdown();

            semaphore.acquire(rand);
            initialPermits -= rand;
            assertEquals(initialPermits, semaphore.availablePermits());
            semaphore.release(rand);
            initialPermits += rand;
            assertEquals(initialPermits, semaphore.availablePermits());
        }
    }
View Full Code Here

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

            semaphore.acquire(rand);
            initialPermits -= rand;
            assertEquals(initialPermits, semaphore.availablePermits());
            semaphore.release(rand);
            initialPermits += rand;
            assertEquals(initialPermits, semaphore.availablePermits());
        }
    }

    @Test(timeout = 120000)
    public void testSemaphoreWithFailuresAndJoin() {
View Full Code Here

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

    @Before
    public void start() throws IOException {
        ISemaphore s = getInstance().getSemaphore(name);
        s.reducePermits(100);
        assertEquals(0, s.availablePermits());
    }

    @After
    public void clear() throws IOException {
        ISemaphore s = getInstance().getSemaphore(name);
View Full Code Here

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

    @After
    public void clear() throws IOException {
        ISemaphore s = getInstance().getSemaphore(name);
        s.reducePermits(100);
        assertEquals(0, s.availablePermits());
    }

    @Test
    public void testAcquire() 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 AcquireRequest(name, 3, 0));
        boolean result = (Boolean) getClient().receive();
        assertTrue(result);
        assertEquals(7, s.availablePermits());

        getClient().send(new AcquireRequest(name, 8, 6 * 1000));
        assertEquals(7, s.availablePermits());

        Thread.sleep(2 * 1000);
 
View Full Code Here

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

        boolean result = (Boolean) getClient().receive();
        assertTrue(result);
        assertEquals(7, s.availablePermits());

        getClient().send(new AcquireRequest(name, 8, 6 * 1000));
        assertEquals(7, s.availablePermits());

        Thread.sleep(2 * 1000);

        s.release(1);

View Full Code Here

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

        s.release(1);

        result = (Boolean) getClient().receive();
        assertTrue(result);
        assertEquals(0, s.availablePermits());

        getClient().send(new AcquireRequest(name, 4, 2 * 1000));
        result = (Boolean) getClient().receive();
        assertFalse(result);

View Full Code Here

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

        ISemaphore s = getInstance().getSemaphore(name);

        getClient().send(new InitRequest(name, 10));
        boolean result = (Boolean) getClient().receive();
        assertTrue(result);
        assertEquals(10, s.availablePermits());

        getClient().send(new InitRequest(name, 20));
        result = (Boolean) getClient().receive();
        assertFalse(result);
        assertEquals(10, s.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.