Package com.hazelcast.core

Examples of com.hazelcast.core.MultiMap


        mm.lock(key, -1, TimeUnit.MILLISECONDS);
    }

    @Test
    public void testLockTTL_whenLockedBySelf() throws Exception {
        final MultiMap mm = client.getMultiMap(randomString());
        final Object key = "Key";
        mm.lock(key);
        mm.lock(key, 30, TimeUnit.SECONDS);
        assertTrue(mm.isLocked(key));
    }
View Full Code Here


        assertTrue(mm.isLocked(key));
    }

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

        mm.lock(key, 1, TimeUnit.SECONDS);
        sleepSeconds(2);
        assertFalse(mm.isLocked(key));
    }
View Full Code Here

        assertFalse(mm.isLocked(key));
    }

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

        mm.lock(key);
        mm.lock(key, 1, TimeUnit.SECONDS);
        sleepSeconds(2);
        assertFalse(mm.isLocked(key));
    }
View Full Code Here

        assertFalse(mm.isLocked(key));
    }

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

        mm.lock(key, 2, TimeUnit.SECONDS);
        final CountDownLatch tryLockSuccess = new CountDownLatch(1);
        new Thread() {
            public void run() {
                try {
                    if (mm.tryLock(key, 4, TimeUnit.SECONDS)) {
                        tryLockSuccess.countDown();
                    }
                } catch (InterruptedException e) {
                    fail(e.getMessage());
                }
View Full Code Here

        }

        for (int i = 0; i < putThreads.length; i++) {
            putThreads[i].start();
        }
        MultiMap multiMap = server.getMultiMap(MAP_NAME);


        assertJoinable(MAX_SECONDS, putThreads);

        final int expectedSize = PutItemsThread.MAX_ITEMS * putThreads.length;
        assertEquals(expectedSize, multiMap.size());
        assertReceivedEventsSize(expectedSize, putThreads);

    }
View Full Code Here

        Hazelcast.shutdownAll();
    }

    @Test(expected = UnsupportedOperationException.class)
    public void testAddLocalEntryListener_whenNull() {
        final MultiMap mm = client.getMultiMap(randomString());
        mm.addLocalEntryListener(null);
    }
View Full Code Here

        mm.addLocalEntryListener(null);
    }

    @Test(expected = UnsupportedOperationException.class)
    public void testAddLocalEntryListener() {
        final MultiMap mm = client.getMultiMap(randomString());
        MyEntryListener myEntryListener = new CountDownValueNotNullListener(1);
        mm.addLocalEntryListener(myEntryListener);
    }
View Full Code Here

        mm.addLocalEntryListener(myEntryListener);
    }

    @Test(expected = IllegalArgumentException.class)
    public void testAddListener_whenListenerNull() throws InterruptedException {
        final MultiMap mm = client.getMultiMap(randomString());
        mm.addEntryListener(null, true);
    }
View Full Code Here

        mm.addEntryListener(null, true);
    }

    @Test
    public void testRemoveListener() throws InterruptedException {
        final MultiMap mm = client.getMultiMap(randomString());

        MyEntryListener listener = new CountDownValueNotNullListener(1);
        final String id = mm.addEntryListener(listener, true);

        assertTrue(mm.removeEntryListener(id));
    }
View Full Code Here

    }


    @Test
    public void testRemoveListener_whenNotExist() throws InterruptedException {
        final MultiMap mm = client.getMultiMap(randomString());

        assertFalse(mm.removeEntryListener("NOT_THERE"));
    }
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.