Package com.hazelcast.core

Examples of com.hazelcast.core.MultiMap


        mm.tryLock(null);
    }

    @Test
    public void testTryLock_whenLockedBySelf() throws Exception {
        final MultiMap mm = client.getMultiMap(randomString());
        final Object key = "Key";
        mm.lock(key);
        assertTrue(mm.tryLock(key));
    }
View Full Code Here


        assertTrue(mm.tryLock(key));
    }

    @Test
    public void testTryLock_whenLockedByOther() throws Exception {
        final MultiMap mm = client.getMultiMap(randomString());
        final Object key = "Key1";
        mm.lock(key);
        final CountDownLatch tryLockFailed = new CountDownLatch(1);
        new Thread() {
            public void run() {
                if (mm.tryLock(key) == false) {
                    tryLockFailed.countDown();
                }
            }
        }.start();
        assertOpenEventually(tryLockFailed);
View Full Code Here

        assertOpenEventually(tryLockFailed);
    }

    @Test
    public void testTryLockWaitingOnLockedKey_thenKeyUnlockedByOtherThread() throws Exception {
        final MultiMap mm = client.getMultiMap(randomString());
        final Object key = "keyZ";

        mm.lock(key);

        final CountDownLatch tryLockReturnsTrue = new CountDownLatch(1);
        new Thread(){
            public void run() {
                try {
                    if(mm.tryLock(key, 10, TimeUnit.SECONDS)){
                        tryLockReturnsTrue.countDown();
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }.start();

        mm.unlock(key);

        assertOpenEventually(tryLockReturnsTrue);
        assertTrue(mm.isLocked(key));
    }
View Full Code Here

        assertTrue(mm.isLocked(key));
    }

    @Test(expected = NullPointerException.class)
    public void testForceUnlock_whenKeyNull() throws Exception {
        final MultiMap mm = client.getMultiMap(randomString());
        mm.forceUnlock(null);
    }
View Full Code Here

        mm.forceUnlock(null);
    }

    @Test
    public void testForceUnlock_whenKeyLocked() throws Exception {
        final MultiMap mm = client.getMultiMap(randomString());
        final Object key = "Key";
        mm.lock(key);
        mm.forceUnlock(key);
        assertFalse(mm.isLocked(key));
    }
View Full Code Here

        assertFalse(mm.isLocked(key));
    }

    @Test
    public void testForceUnlock_whenKeyLockedTwice() throws Exception {
        final MultiMap mm = client.getMultiMap(randomString());
        final Object key = "Key";
        mm.lock(key);
        mm.lock(key);
        mm.forceUnlock(key);
        assertFalse(mm.isLocked(key));
    }
View Full Code Here

        assertFalse(mm.isLocked(key));
    }

    @Test
    public void testForceUnlock_whenKeyLockedByOther() throws Exception {
        final MultiMap mm = client.getMultiMap(randomString());
        final Object key = "key";
        mm.lock(key);
        final CountDownLatch forceUnlock = new CountDownLatch(1);
        new Thread(){
            public void run() {
                mm.forceUnlock(key);
                forceUnlock.countDown();
            }
        }.start();
        assertOpenEventually(forceUnlock);
        assertFalse(mm.isLocked(key));
    }
View Full Code Here

        assertFalse(mm.isLocked(key));
    }

    @Test
    public void testForceUnlock_whenKeyLockedTwiceByOther() throws Exception {
        final MultiMap mm = client.getMultiMap(randomString());
        final Object key = "key";
        mm.lock(key);
        mm.lock(key);
        final CountDownLatch forceUnlock = new CountDownLatch(1);
        new Thread(){
            public void run() {
                mm.forceUnlock(key);
                forceUnlock.countDown();
            }
        }.start();
        assertOpenEventually(forceUnlock);
        assertFalse(mm.isLocked(key));
    }
View Full Code Here

        assertFalse(mm.isLocked(key));
    }

    @Test
    public void testLockTTL() throws Exception {
        final MultiMap mm = client.getMultiMap(randomString());
        final Object key = "Key";

        mm.lock(key, 30, TimeUnit.SECONDS);
        assertTrue(mm.isLocked(key));
    }
View Full Code Here

        assertTrue(mm.isLocked(key));
    }

    @Test(expected = IllegalArgumentException.class)
    public void testLockTTL_whenZeroTimeout() throws Exception {
        final MultiMap mm = client.getMultiMap(randomString());
        final Object key = "Key";
        mm.lock(key, 0, TimeUnit.SECONDS);
    }
View Full Code Here

TOP

Related Classes of com.hazelcast.core.MultiMap

Copyright © 2018 www.massapicom. 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.