Package com.hazelcast.core

Examples of com.hazelcast.core.IMap.lock()


        }, 2);
        addOperation(operations, new Runnable() {
            public void run() {
                IMap map = hazelcast.getMap("myMap");
                int key = random.nextInt(SIZE);
                map.lock(key);
                try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                } finally {
View Full Code Here


        }, 2);
        addOperation(operations, new Runnable() {
            public void run() {
                IMap map = hazelcast.getMap("myMap");
                int key = random.nextInt(SIZE);
                map.lock(key);
                try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                } finally {
View Full Code Here

    @Test
    public void testTryPutRemove() throws Exception {
        final IMap map = createMap();
        assertTrue(map.tryPut("key1", "value1", 1, TimeUnit.SECONDS));
        assertTrue(map.tryPut("key2", "value2", 1, TimeUnit.SECONDS));
        map.lock("key1");
        map.lock("key2");

        final CountDownLatch latch = new CountDownLatch(2);

        new Thread() {
View Full Code Here

    public void testTryPutRemove() throws Exception {
        final IMap map = createMap();
        assertTrue(map.tryPut("key1", "value1", 1, TimeUnit.SECONDS));
        assertTrue(map.tryPut("key2", "value2", 1, TimeUnit.SECONDS));
        map.lock("key1");
        map.lock("key2");

        final CountDownLatch latch = new CountDownLatch(2);

        new Thread() {
            public void run() {
View Full Code Here

    @Test
    public void testLock() throws Exception {
        final IMap map = createMap();
        map.put("key1", "value1");
        assertEquals("value1", map.get("key1"));
        map.lock("key1");
        final CountDownLatch latch = new CountDownLatch(1);
        new Thread() {
            public void run() {
                map.tryPut("key1", "value2", 1, TimeUnit.SECONDS);
                latch.countDown();
View Full Code Here

    @Test
    public void testLockTtl() throws Exception {
        final IMap map = createMap();
        map.put("key1", "value1");
        assertEquals("value1", map.get("key1"));
        map.lock("key1", 2, TimeUnit.SECONDS);
        final CountDownLatch latch = new CountDownLatch(1);
        new Thread() {
            public void run() {
                map.tryPut("key1", "value2", 5, TimeUnit.SECONDS);
                latch.countDown();
View Full Code Here

    }

    @Test
    public void testLockTtl2() throws Exception {
        final IMap map = createMap();
        map.lock("key1", 3, TimeUnit.SECONDS);
        final CountDownLatch latch = new CountDownLatch(2);
        new Thread() {
            public void run() {
                if (!map.tryLock("key1")) {
                    latch.countDown();
View Full Code Here

    }

    @Test
    public void testForceUnlock() throws Exception {
        final IMap map = createMap();
        map.lock("key1");
        final CountDownLatch latch = new CountDownLatch(1);
        new Thread() {
            public void run() {
                map.forceUnlock("key1");
                latch.countDown();
View Full Code Here

    }

    @Test
    public void testMapIsLocked() throws IOException {
        final IMap map = getMap();
        map.lock(1);
        final SimpleClient client = getClient();
        client.send(new MapIsLockedRequest(mapName, TestUtil.toData(1)));
        assertEquals(true, client.receive());
        map.unlock(1);
        client.send(new MapIsLockedRequest(mapName, TestUtil.toData(1)));
View Full Code Here

        final CountDownLatch latch = new CountDownLatch(1);

        Runnable runnable = new Runnable() {
            public void run() {
                for (int i = 0; i < size; i++) {
                    map1.lock(i);
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                    }
                }
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.