Package com.hazelcast.core

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


            }
        }.start();

        latch0.await();

        lock.lock(1000, TimeUnit.MILLISECONDS);

        assertTrue(lock.isLocked());
        sleepSeconds(2);
        assertFalse(lock.isLocked());
    }
View Full Code Here


    @Test(timeout = 60000)
    public void testLockLeaseTime_lockIsReleasedEventually() throws InterruptedException {
        HazelcastInstance instance = createHazelcastInstance();
        final ILock lock = instance.getLock(randomString());

        lock.lock(1000, TimeUnit.MILLISECONDS);
        assertTrue(lock.isLocked());

        lock.lock();
        assertTrue(lock.isLocked());
    }
View Full Code Here

        final ILock lock = instance.getLock(randomString());

        lock.lock(1000, TimeUnit.MILLISECONDS);
        assertTrue(lock.isLocked());

        lock.lock();
        assertTrue(lock.isLocked());
    }


    // =======================================================================
View Full Code Here

    public void testTryLock_whenMultipleThreads() throws InterruptedException {
        HazelcastInstance instance = createHazelcastInstance();
        final AtomicInteger atomicInteger = new AtomicInteger(0);
        final ILock lock = instance.getLock("testSimpleUsage");

        lock.lock();

        Runnable tryLockRunnable = new Runnable() {
            public void run() {
                if (lock.tryLock()) {
                    atomicInteger.incrementAndGet();
View Full Code Here

        HazelcastInstance instance = createHazelcastInstance();
        final ILock lock = instance.getLock(randomString());

        assertFalse(lock.isLocked());

        lock.lock();
        assertTrue(lock.isLocked());
        lock.unlock();

        assertFalse(lock.isLocked());
    }
View Full Code Here

    public void testDestroyLockWhenOtherWaitingOnLock() throws InterruptedException {
        final HazelcastInstance instance = createHazelcastInstance();
        final ILock lock = instance.getLock("testLockDestroyWhenWaitingLock");
        Thread t = new Thread(new Runnable() {
            public void run() {
                lock.lock();
            }
        });
        t.start();
        t.join();
View Full Code Here

                }
                lock.destroy();
            }
        }).start();

        lock.lock();

    }

    @Test(expected = HazelcastInstanceNotActiveException.class)
    public void testShutDownNodeWhenOtherWaitingOnLockLocalKey() throws InterruptedException {
View Full Code Here

        }

        final ILock lock = instance.getLock(key);
        Thread thread = new Thread(new Runnable() {
            public void run() {
                lock.lock();
            }
        });
        thread.start();
        thread.join();
        new Thread(new Runnable() {
View Full Code Here

                    e.printStackTrace();
                }
                instance.shutdown();
            }
        }).start();
        lock.lock();
    }


    @Test(timeout = 100000)
    public void testLockEvictionLocalKey() throws Exception {
View Full Code Here

        } else {
            key = generateKeyNotOwnedBy(instance1);
        }

        final ILock lock = instance1.getLock(key);
        lock.lock(10, TimeUnit.SECONDS);
        assertTrue(lock.getRemainingLeaseTime() > 0);
        assertTrue(lock.isLocked());

        final CountDownLatch latch = new CountDownLatch(1);
        Thread t = new Thread(new Runnable() {
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.