Search in sources :

Example 1 with LockStoreContainer

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

the class LockReplicationOperation method run.

@Override
public void run() {
    LockSupportServiceImpl lockService = getService();
    LockStoreContainer container = lockService.getLockContainer(getPartitionId());
    for (LockStoreImpl ls : locks) {
        container.put(ls);
    }
}
Also used : LockStoreImpl(com.hazelcast.internal.locksupport.LockStoreImpl) LockSupportServiceImpl(com.hazelcast.internal.locksupport.LockSupportServiceImpl) LockStoreContainer(com.hazelcast.internal.locksupport.LockStoreContainer)

Example 2 with LockStoreContainer

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

the class MapLockTest method lockStoreShouldBeRemoved_whenMapIsDestroyed.

/**
 * See issue #4888
 */
@Test
public void lockStoreShouldBeRemoved_whenMapIsDestroyed() {
    HazelcastInstance instance = createHazelcastInstance(getConfig());
    IMap<Integer, Integer> map = instance.getMap(randomName());
    for (int i = 0; i < 1000; i++) {
        map.lock(i);
    }
    map.destroy();
    NodeEngineImpl nodeEngine = getNodeEngineImpl(instance);
    LockSupportServiceImpl lockService = nodeEngine.getService(LockSupportService.SERVICE_NAME);
    int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
    for (int i = 0; i < partitionCount; i++) {
        LockStoreContainer lockContainer = lockService.getLockContainer(i);
        Collection<LockStoreImpl> lockStores = lockContainer.getLockStores().stream().filter(s -> !s.getNamespace().getObjectName().startsWith(JobRepository.INTERNAL_JET_OBJECTS_PREFIX)).collect(Collectors.toList());
        assertEquals("LockStores should be empty", 0, lockStores.size());
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) LockStoreImpl(com.hazelcast.internal.locksupport.LockStoreImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) RunWith(org.junit.runner.RunWith) Random(java.util.Random) TransactionException(com.hazelcast.transaction.TransactionException) LockSupportService(com.hazelcast.internal.locksupport.LockSupportService) LockSupportServiceImpl(com.hazelcast.internal.locksupport.LockSupportServiceImpl) JobRepository(com.hazelcast.jet.impl.JobRepository) Config(com.hazelcast.config.Config) HazelcastInstance(com.hazelcast.core.HazelcastInstance) NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) LockStoreContainer(com.hazelcast.internal.locksupport.LockStoreContainer) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) LockStoreImpl(com.hazelcast.internal.locksupport.LockStoreImpl) HazelcastTestSupport(com.hazelcast.test.HazelcastTestSupport) Collection(java.util.Collection) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) Collectors(java.util.stream.Collectors) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) Assert.assertFalse(org.junit.Assert.assertFalse) HazelcastParallelClassRunner(com.hazelcast.test.HazelcastParallelClassRunner) AssertTask(com.hazelcast.test.AssertTask) Assert.assertEquals(org.junit.Assert.assertEquals) HazelcastInstance(com.hazelcast.core.HazelcastInstance) LockSupportServiceImpl(com.hazelcast.internal.locksupport.LockSupportServiceImpl) LockStoreContainer(com.hazelcast.internal.locksupport.LockStoreContainer) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 3 with LockStoreContainer

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

the class MultiMapLockTest method lockStoreShouldBeRemoved_whenMultimapIsDestroyed.

/**
 * See issue #4888
 */
@Test
public void lockStoreShouldBeRemoved_whenMultimapIsDestroyed() {
    HazelcastInstance hz = createHazelcastInstance();
    MultiMap<String, Integer> multiMap = hz.getMultiMap(randomName());
    for (int i = 0; i < 1000; i++) {
        multiMap.lock("" + i);
    }
    multiMap.destroy();
    NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
    LockSupportServiceImpl lockService = nodeEngine.getService(LockSupportService.SERVICE_NAME);
    int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
    for (int i = 0; i < partitionCount; i++) {
        LockStoreContainer lockContainer = lockService.getLockContainer(i);
        Collection<LockStoreImpl> lockStores = lockContainer.getLockStores().stream().filter(s -> !s.getNamespace().getObjectName().startsWith(JobRepository.INTERNAL_JET_OBJECTS_PREFIX)).collect(Collectors.toList());
        assertEquals("LockStores should be empty: " + lockStores, 0, lockStores.size());
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) LockStoreImpl(com.hazelcast.internal.locksupport.LockStoreImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) RunWith(org.junit.runner.RunWith) MultiMapConfig(com.hazelcast.config.MultiMapConfig) LockSupportService(com.hazelcast.internal.locksupport.LockSupportService) LockSupportServiceImpl(com.hazelcast.internal.locksupport.LockSupportServiceImpl) JobRepository(com.hazelcast.jet.impl.JobRepository) Config(com.hazelcast.config.Config) HazelcastInstance(com.hazelcast.core.HazelcastInstance) NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) LockStoreContainer(com.hazelcast.internal.locksupport.LockStoreContainer) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) LockStoreImpl(com.hazelcast.internal.locksupport.LockStoreImpl) HazelcastTestSupport(com.hazelcast.test.HazelcastTestSupport) Collection(java.util.Collection) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) Collectors(java.util.stream.Collectors) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) Assert.assertFalse(org.junit.Assert.assertFalse) HazelcastParallelClassRunner(com.hazelcast.test.HazelcastParallelClassRunner) AssertTask(com.hazelcast.test.AssertTask) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) HazelcastInstance(com.hazelcast.core.HazelcastInstance) LockSupportServiceImpl(com.hazelcast.internal.locksupport.LockSupportServiceImpl) LockStoreContainer(com.hazelcast.internal.locksupport.LockStoreContainer) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

LockStoreContainer (com.hazelcast.internal.locksupport.LockStoreContainer)3 LockStoreImpl (com.hazelcast.internal.locksupport.LockStoreImpl)3 LockSupportServiceImpl (com.hazelcast.internal.locksupport.LockSupportServiceImpl)3 Config (com.hazelcast.config.Config)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 LockSupportService (com.hazelcast.internal.locksupport.LockSupportService)2 JobRepository (com.hazelcast.jet.impl.JobRepository)2 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)2 Accessors.getNodeEngineImpl (com.hazelcast.test.Accessors.getNodeEngineImpl)2 AssertTask (com.hazelcast.test.AssertTask)2 HazelcastParallelClassRunner (com.hazelcast.test.HazelcastParallelClassRunner)2 HazelcastTestSupport (com.hazelcast.test.HazelcastTestSupport)2 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Collection (java.util.Collection)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 TimeUnit (java.util.concurrent.TimeUnit)2 Collectors (java.util.stream.Collectors)2 Assert.assertEquals (org.junit.Assert.assertEquals)2