Search in sources :

Example 21 with LockStoreImpl

use of com.hazelcast.concurrent.lock.LockStoreImpl in project hazelcast by hazelcast.

the class UnlockOperation method unlock.

protected final void unlock() {
    LockStoreImpl lockStore = getLockStore();
    boolean unlocked = lockStore.unlock(key, getCallerUuid(), threadId, getReferenceCallId());
    response = unlocked;
    if (!unlocked) {
        // we can not check for retry here, hence just throw the exception
        String ownerInfo = lockStore.getOwnerInfo(key);
        throw new IllegalMonitorStateException("Current thread is not owner of the lock! -> " + ownerInfo);
    }
}
Also used : LockStoreImpl(com.hazelcast.concurrent.lock.LockStoreImpl)

Example 22 with LockStoreImpl

use of com.hazelcast.concurrent.lock.LockStoreImpl in project hazelcast by hazelcast.

the class UnlockOperation method forceUnlock.

protected final void forceUnlock() {
    LockStoreImpl lockStore = getLockStore();
    response = lockStore.forceUnlock(key);
}
Also used : LockStoreImpl(com.hazelcast.concurrent.lock.LockStoreImpl)

Example 23 with LockStoreImpl

use of com.hazelcast.concurrent.lock.LockStoreImpl in project hazelcast by hazelcast.

the class MultiMapLockTest method lockStoreShouldBeRemoved_whenMultimapIsDestroyed.

/**
     * See issue #4888
     */
@Test
public void lockStoreShouldBeRemoved_whenMultimapIsDestroyed() {
    HazelcastInstance hz = createHazelcastInstance();
    MultiMap multiMap = hz.getMultiMap(randomName());
    for (int i = 0; i < 1000; i++) {
        multiMap.lock(i);
    }
    multiMap.destroy();
    NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
    LockServiceImpl lockService = nodeEngine.getService(LockService.SERVICE_NAME);
    int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
    for (int i = 0; i < partitionCount; i++) {
        LockStoreContainer lockContainer = lockService.getLockContainer(i);
        Collection<LockStoreImpl> lockStores = lockContainer.getLockStores();
        assertEquals("LockStores should be empty: " + lockStores, 0, lockStores.size());
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) LockStoreImpl(com.hazelcast.concurrent.lock.LockStoreImpl) MultiMap(com.hazelcast.core.MultiMap) HazelcastInstance(com.hazelcast.core.HazelcastInstance) LockServiceImpl(com.hazelcast.concurrent.lock.LockServiceImpl) LockStoreContainer(com.hazelcast.concurrent.lock.LockStoreContainer) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

LockStoreImpl (com.hazelcast.concurrent.lock.LockStoreImpl)23 LockServiceImpl (com.hazelcast.concurrent.lock.LockServiceImpl)2 LockStoreContainer (com.hazelcast.concurrent.lock.LockStoreContainer)2 ILogger (com.hazelcast.logging.ILogger)2 ConditionKey (com.hazelcast.concurrent.lock.ConditionKey)1 LockResource (com.hazelcast.concurrent.lock.LockResource)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 MultiMap (com.hazelcast.core.MultiMap)1 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Test (org.junit.Test)1