Search in sources :

Example 11 with InternalLockNamespace

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

the class ConditionSignalAllMessageTask method prepareOperation.

@Override
protected Operation prepareOperation() {
    final Data key = serializationService.toData(parameters.lockName);
    final InternalLockNamespace namespace = new InternalLockNamespace(parameters.lockName);
    return new SignalOperation(namespace, key, parameters.threadId, parameters.name, true);
}
Also used : InternalLockNamespace(com.hazelcast.concurrent.lock.InternalLockNamespace) SignalOperation(com.hazelcast.concurrent.lock.operations.SignalOperation) Data(com.hazelcast.nio.serialization.Data)

Example 12 with InternalLockNamespace

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

the class PartitionControlledIdTest method testLock.

@Test
public void testLock() throws Exception {
    String partitionKey = "hazelcast";
    HazelcastInstance hz = getHazelcastInstance(partitionKey);
    ILock lock = hz.getLock("lock@" + partitionKey);
    lock.lock();
    assertEquals("lock@" + partitionKey, lock.getName());
    assertEquals(partitionKey, lock.getPartitionKey());
    Node node = getNode(hz);
    LockServiceImpl lockService = node.nodeEngine.getService(LockServiceImpl.SERVICE_NAME);
    Partition partition = instances[0].getPartitionService().getPartition(partitionKey);
    LockStore lockStore = lockService.getLockStore(partition.getPartitionId(), new InternalLockNamespace(lock.getName()));
    Data key = node.getSerializationService().toData(lock.getName(), StringPartitioningStrategy.INSTANCE);
    assertTrue(lockStore.isLocked(key));
}
Also used : Partition(com.hazelcast.core.Partition) HazelcastInstance(com.hazelcast.core.HazelcastInstance) InternalLockNamespace(com.hazelcast.concurrent.lock.InternalLockNamespace) Node(com.hazelcast.instance.Node) LockServiceImpl(com.hazelcast.concurrent.lock.LockServiceImpl) Data(com.hazelcast.nio.serialization.Data) ILock(com.hazelcast.core.ILock) LockStore(com.hazelcast.concurrent.lock.LockStore) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

InternalLockNamespace (com.hazelcast.concurrent.lock.InternalLockNamespace)12 HazelcastInstance (com.hazelcast.core.HazelcastInstance)8 ParallelTest (com.hazelcast.test.annotation.ParallelTest)8 QuickTest (com.hazelcast.test.annotation.QuickTest)8 Test (org.junit.Test)8 LockOperation (com.hazelcast.concurrent.lock.operations.LockOperation)7 Config (com.hazelcast.config.Config)7 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)7 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)7 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)7 Data (com.hazelcast.nio.serialization.Data)5 UnlockOperation (com.hazelcast.concurrent.lock.operations.UnlockOperation)4 OperationTimeoutException (com.hazelcast.core.OperationTimeoutException)4 IsLockedOperation (com.hazelcast.concurrent.lock.operations.IsLockedOperation)3 TimeoutException (java.util.concurrent.TimeoutException)3 SignalOperation (com.hazelcast.concurrent.lock.operations.SignalOperation)2 Operation (com.hazelcast.spi.Operation)2 AssertTask (com.hazelcast.test.AssertTask)2 LockServiceImpl (com.hazelcast.concurrent.lock.LockServiceImpl)1 LockStore (com.hazelcast.concurrent.lock.LockStore)1