Search in sources :

Example 1 with LockService

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

the class PartitionContainer method clearLockStore.

private void clearLockStore(String name) {
    final NodeEngine nodeEngine = mapService.getMapServiceContext().getNodeEngine();
    final LockService lockService = nodeEngine.getSharedService(LockService.SERVICE_NAME);
    if (lockService != null) {
        final DefaultObjectNamespace namespace = new DefaultObjectNamespace(MapService.SERVICE_NAME, name);
        lockService.clearLockStore(partitionId, namespace);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) DefaultObjectNamespace(com.hazelcast.spi.DefaultObjectNamespace) LockService(com.hazelcast.concurrent.lock.LockService)

Example 2 with LockService

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

the class MultiMapPartitionContainer method clearLockStore.

private void clearLockStore(String name) {
    NodeEngine nodeEngine = service.getNodeEngine();
    LockService lockService = nodeEngine.getSharedService(LockService.SERVICE_NAME);
    if (lockService != null) {
        DefaultObjectNamespace namespace = new DefaultObjectNamespace(MultiMapService.SERVICE_NAME, name);
        lockService.clearLockStore(partitionId, namespace);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) DefaultObjectNamespace(com.hazelcast.spi.DefaultObjectNamespace) LockService(com.hazelcast.concurrent.lock.LockService)

Example 3 with LockService

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

the class MapTransactionTest method testGetForUpdate_releasesBackupLock.

@Test
public void testGetForUpdate_releasesBackupLock() {
    Config config = getConfig();
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    HazelcastInstance instance1 = factory.newHazelcastInstance(config);
    HazelcastInstance instance2 = factory.newHazelcastInstance(config);
    final String keyOwnedByInstance2 = generateKeyOwnedBy(instance2);
    instance1.executeTransaction(new TransactionalTask<Object>() {

        @Override
        public Object execute(TransactionalTaskContext context) throws TransactionException {
            TransactionalMap<Object, Object> map = context.getMap(randomString());
            map.getForUpdate(keyOwnedByInstance2);
            return null;
        }
    });
    Node node = TestUtil.getNode(instance1);
    Data keyData = node.nodeEngine.toData(keyOwnedByInstance2);
    LockService lockService = node.nodeEngine.getService(LockService.SERVICE_NAME);
    for (LockResource lockResource : lockService.getAllLocks()) {
        if (keyData.equals(lockResource.getKey())) {
            assertEquals(0, lockResource.getLockCount());
        }
    }
}
Also used : TransactionalMap(com.hazelcast.core.TransactionalMap) LockService(com.hazelcast.concurrent.lock.LockService) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Config(com.hazelcast.config.Config) Node(com.hazelcast.instance.Node) TransactionalTaskContext(com.hazelcast.transaction.TransactionalTaskContext) Data(com.hazelcast.nio.serialization.Data) HazelcastInstance(com.hazelcast.core.HazelcastInstance) TransactionException(com.hazelcast.transaction.TransactionException) LockResource(com.hazelcast.concurrent.lock.LockResource) Mockito.anyObject(org.mockito.Mockito.anyObject) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 4 with LockService

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

the class MapManagedService method init.

@Override
public void init(NodeEngine nodeEngine, Properties properties) {
    final LockService lockService = nodeEngine.getSharedService(LockService.SERVICE_NAME);
    if (lockService != null) {
        lockService.registerLockStoreConstructor(MapService.SERVICE_NAME, new ObjectNamespaceLockStoreInfoConstructorFunction());
    }
    mapServiceContext.initPartitionsContainers();
    mapServiceContext.getExpirationManager().start();
}
Also used : LockService(com.hazelcast.concurrent.lock.LockService)

Example 5 with LockService

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

the class MultiMapContainer method destroy.

public void destroy() {
    final LockService lockService = nodeEngine.getSharedService(LockService.SERVICE_NAME);
    if (lockService != null) {
        lockService.clearLockStore(partitionId, lockNamespace);
    }
    multiMapValues.clear();
}
Also used : LockService(com.hazelcast.concurrent.lock.LockService)

Aggregations

LockService (com.hazelcast.concurrent.lock.LockService)8 DefaultObjectNamespace (com.hazelcast.spi.DefaultObjectNamespace)4 NodeEngine (com.hazelcast.spi.NodeEngine)4 Data (com.hazelcast.nio.serialization.Data)2 LockResource (com.hazelcast.concurrent.lock.LockResource)1 LockStoreInfo (com.hazelcast.concurrent.lock.LockStoreInfo)1 Config (com.hazelcast.config.Config)1 MapStoreConfig (com.hazelcast.config.MapStoreConfig)1 MultiMapConfig (com.hazelcast.config.MultiMapConfig)1 NativeMemoryConfig (com.hazelcast.config.NativeMemoryConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 TransactionalMap (com.hazelcast.core.TransactionalMap)1 Node (com.hazelcast.instance.Node)1 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)1 Record (com.hazelcast.map.impl.record.Record)1 Indexes (com.hazelcast.query.impl.Indexes)1 ObjectNamespace (com.hazelcast.spi.ObjectNamespace)1 MigrationEndpoint (com.hazelcast.spi.partition.MigrationEndpoint)1 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)1 NightlyTest (com.hazelcast.test.annotation.NightlyTest)1