Search in sources :

Example 1 with LockSupportService

use of com.hazelcast.internal.locksupport.LockSupportService in project hazelcast by hazelcast.

the class PartitionContainer method clearLockStore.

private void clearLockStore(String name) {
    final NodeEngine nodeEngine = mapService.getMapServiceContext().getNodeEngine();
    final LockSupportService lockService = nodeEngine.getServiceOrNull(LockSupportService.SERVICE_NAME);
    if (lockService != null) {
        final ObjectNamespace namespace = MapService.getObjectNamespace(name);
        lockService.clearLockStore(partitionId, namespace);
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) LockSupportService(com.hazelcast.internal.locksupport.LockSupportService) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace)

Example 2 with LockSupportService

use of com.hazelcast.internal.locksupport.LockSupportService in project hazelcast by hazelcast.

the class MultiMapPartitionContainer method clearLockStore.

private void clearLockStore(String name) {
    NodeEngine nodeEngine = service.getNodeEngine();
    LockSupportService lockService = nodeEngine.getServiceOrNull(LockSupportService.SERVICE_NAME);
    if (lockService != null) {
        DistributedObjectNamespace namespace = new DistributedObjectNamespace(MultiMapService.SERVICE_NAME, name);
        lockService.clearLockStore(partitionId, namespace);
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) DistributedObjectNamespace(com.hazelcast.internal.services.DistributedObjectNamespace) LockSupportService(com.hazelcast.internal.locksupport.LockSupportService)

Example 3 with LockSupportService

use of com.hazelcast.internal.locksupport.LockSupportService 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;
        }
    });
    NodeEngine nodeEngine = getNodeEngineImpl(instance1);
    Data keyData = nodeEngine.toData(keyOwnedByInstance2);
    LockSupportService lockService = nodeEngine.getService(LockSupportService.SERVICE_NAME);
    for (LockResource lockResource : lockService.getAllLocks()) {
        if (keyData.equals(lockResource.getKey())) {
            assertEquals(0, lockResource.getLockCount());
        }
    }
}
Also used : TransactionalMap(com.hazelcast.transaction.TransactionalMap) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Config(com.hazelcast.config.Config) TransactionalTaskContext(com.hazelcast.transaction.TransactionalTaskContext) Data(com.hazelcast.internal.serialization.Data) LockSupportService(com.hazelcast.internal.locksupport.LockSupportService) NodeEngine(com.hazelcast.spi.impl.NodeEngine) HazelcastInstance(com.hazelcast.core.HazelcastInstance) TransactionException(com.hazelcast.transaction.TransactionException) LockResource(com.hazelcast.internal.locksupport.LockResource) Mockito.anyObject(org.mockito.Mockito.anyObject) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 4 with LockSupportService

use of com.hazelcast.internal.locksupport.LockSupportService in project hazelcast by hazelcast.

the class MapManagedService method init.

@Override
public void init(NodeEngine nodeEngine, Properties properties) {
    final LockSupportService lockService = nodeEngine.getServiceOrNull(LockSupportService.SERVICE_NAME);
    if (lockService != null) {
        lockService.registerLockStoreConstructor(MapService.SERVICE_NAME, new ObjectNamespaceLockStoreInfoConstructorFunction());
    }
    mapServiceContext.initPartitionsContainers();
}
Also used : LockSupportService(com.hazelcast.internal.locksupport.LockSupportService)

Example 5 with LockSupportService

use of com.hazelcast.internal.locksupport.LockSupportService in project hazelcast by hazelcast.

the class DefaultRecordStore method clearLockStore.

private void clearLockStore() {
    NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    LockSupportService lockService = nodeEngine.getServiceOrNull(LockSupportService.SERVICE_NAME);
    if (lockService != null) {
        ObjectNamespace namespace = MapService.getObjectNamespace(name);
        lockService.clearLockStore(partitionId, namespace);
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) LockSupportService(com.hazelcast.internal.locksupport.LockSupportService) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace)

Aggregations

LockSupportService (com.hazelcast.internal.locksupport.LockSupportService)8 NodeEngine (com.hazelcast.spi.impl.NodeEngine)5 ObjectNamespace (com.hazelcast.internal.services.ObjectNamespace)2 Config (com.hazelcast.config.Config)1 MapStoreConfig (com.hazelcast.config.MapStoreConfig)1 MultiMapConfig (com.hazelcast.config.MultiMapConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 ConfigValidator.checkMultiMapConfig (com.hazelcast.internal.config.ConfigValidator.checkMultiMapConfig)1 LockResource (com.hazelcast.internal.locksupport.LockResource)1 LockStoreInfo (com.hazelcast.internal.locksupport.LockStoreInfo)1 Data (com.hazelcast.internal.serialization.Data)1 DistributedObjectNamespace (com.hazelcast.internal.services.DistributedObjectNamespace)1 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)1 NightlyTest (com.hazelcast.test.annotation.NightlyTest)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 TransactionException (com.hazelcast.transaction.TransactionException)1 TransactionalMap (com.hazelcast.transaction.TransactionalMap)1 TransactionalTaskContext (com.hazelcast.transaction.TransactionalTaskContext)1 Test (org.junit.Test)1