Search in sources :

Example 1 with LockStore

use of com.hazelcast.concurrent.lock.LockStore 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)1 LockServiceImpl (com.hazelcast.concurrent.lock.LockServiceImpl)1 LockStore (com.hazelcast.concurrent.lock.LockStore)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 ILock (com.hazelcast.core.ILock)1 Partition (com.hazelcast.core.Partition)1 Node (com.hazelcast.instance.Node)1 Data (com.hazelcast.nio.serialization.Data)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Test (org.junit.Test)1