Package com.hazelcast.core

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


    @Test
    public void testTryAcquireMultiPermits_whenUnAvailable() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
        semaphore.init(5);
        assertFalse(semaphore.tryAcquire(10));
    }

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


    @Test
    public void testTryAcquireMultiPermits_whenAvailableWithTimeOut() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
        semaphore.init(10);
        assertTrue(semaphore.tryAcquire(5, 1, TimeUnit.MILLISECONDS));
    }

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

    @Test
    public void testTryAcquireMultiPermits_whenUnAvailableWithTimeOut() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
        semaphore.init(5);
        assertFalse(semaphore.tryAcquire(10, 1, TimeUnit.MILLISECONDS));
    }

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

    @Test
    public void testTryAcquire_afterRelease() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
        semaphore.init(0);
        semaphore.release();
        assertTrue(semaphore.tryAcquire());
    }

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

    @Test
    public void testMulitReleaseTryAcquire() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
        semaphore.init(0);
        semaphore.release(5);
        assertTrue(semaphore.tryAcquire(5));
    }

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

        final CountDownLatch latch = new CountDownLatch(1);
        new Thread(){
            public void run() {
                try {
                    if(semaphore.tryAcquire(1, 5, TimeUnit.SECONDS)){
                        latch.countDown();
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
View Full Code Here

    @Test
    public void testTryAcquire_whenDrainPermits() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
        semaphore.init(10);
        semaphore.drainPermits();
        assertFalse(semaphore.tryAcquire());
    }

    @Test
    public void testAvailablePermits() 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.