Package com.hazelcast.core

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


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

        boolean result = lock.tryLock(1, TimeUnit.SECONDS);

        assertTrue(result);
        assertTrue(lock.isLockedByCurrentThread());
View Full Code Here


        final CountDownLatch latch = new CountDownLatch(1);
        new Thread(new Runnable() {
            @Override
            public void run() {
                lock.lock();
                latch.countDown();
                sleepSeconds(1);
                lock.unlock();
            }
        }).start();
View Full Code Here

    @Test(timeout = 60000)
    public void testUnlock_whenLockedBySelf() {
        HazelcastInstance instance = createHazelcastInstance();
        ILock lock = instance.getLock(randomString());
        lock.lock();

        lock.unlock();

        assertFalse(lock.isLocked());
        assertEquals(0, lock.getLockCount());
View Full Code Here

    @Test(timeout = 60000)
    public void testUnlock_whenReentrantlyLockedBySelf() {
        HazelcastInstance instance = createHazelcastInstance();
        ILock lock = instance.getLock("testUnlock_whenReentrantlyLockedBySelf");
        lock.lock();
        lock.lock();

        lock.unlock();

        assertTrue(lock.isLockedByCurrentThread());
View Full Code Here

    @Test(timeout = 60000)
    public void testUnlock_whenReentrantlyLockedBySelf() {
        HazelcastInstance instance = createHazelcastInstance();
        ILock lock = instance.getLock("testUnlock_whenReentrantlyLockedBySelf");
        lock.lock();
        lock.lock();

        lock.unlock();

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

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

        lock.lock();
        final CountDownLatch latch = new CountDownLatch(1);
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                lock.lock();
View Full Code Here

        lock.lock();
        final CountDownLatch latch = new CountDownLatch(1);
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                lock.lock();
                latch.countDown();

            }
        });
        thread.start();
View Full Code Here

    @Test(timeout = 60000)
    public void testForceUnlock_whenOwnedByOtherThread() {
        HazelcastInstance instance = createHazelcastInstance();
        ILock lock = instance.getLock(randomString());
        lock.lock();

        lock.forceUnlock();

        assertFalse(lock.isLocked());
        assertEquals(0, lock.getLockCount());
View Full Code Here

    @Test(timeout = 60000)
    public void testForceUnlock_whenAcquiredByCurrentThread() {
        HazelcastInstance instance = createHazelcastInstance();
        ILock lock = instance.getLock(randomString());
        lock.lock();

        lock.forceUnlock();

        assertFalse(lock.isLocked());
        assertEquals(0, lock.getLockCount());
View Full Code Here

    @Test(timeout = 60000)
    public void testForceUnlock_whenAcquiredMultipleTimesByCurrentThread() {
        HazelcastInstance instance = createHazelcastInstance();
        ILock lock = instance.getLock(randomString());
        lock.lock();
        lock.lock();

        lock.forceUnlock();

        assertFalse(lock.isLocked());
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.