Search in sources :

Example 1 with LockSupportServiceImpl

use of com.hazelcast.internal.locksupport.LockSupportServiceImpl 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 LockSupportServiceImpl

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

the class ServiceManagerImpl method registerDefaultServices.

private void registerDefaultServices(ServicesConfig servicesConfig) {
    if (!servicesConfig.isEnableDefaults()) {
        return;
    }
    logger.finest("Registering default services...");
    registerService(MapService.SERVICE_NAME, createService(MapService.class));
    registerService(LockSupportService.SERVICE_NAME, new LockSupportServiceImpl(nodeEngine));
    registerService(QueueService.SERVICE_NAME, new QueueService(nodeEngine));
    registerService(TopicService.SERVICE_NAME, new TopicService());
    registerService(ReliableTopicService.SERVICE_NAME, new ReliableTopicService(nodeEngine));
    registerService(MultiMapService.SERVICE_NAME, new MultiMapService(nodeEngine));
    registerService(ListService.SERVICE_NAME, new ListService(nodeEngine));
    registerService(SetService.SERVICE_NAME, new SetService(nodeEngine));
    registerService(DistributedExecutorService.SERVICE_NAME, new DistributedExecutorService());
    registerService(DistributedDurableExecutorService.SERVICE_NAME, new DistributedDurableExecutorService(nodeEngine));
    registerService(FlakeIdGeneratorService.SERVICE_NAME, new FlakeIdGeneratorService(nodeEngine));
    registerService(ReplicatedMapService.SERVICE_NAME, new ReplicatedMapService(nodeEngine));
    registerService(RingbufferService.SERVICE_NAME, new RingbufferService(nodeEngine));
    registerService(XAService.SERVICE_NAME, new XAService(nodeEngine));
    registerService(CardinalityEstimatorService.SERVICE_NAME, new CardinalityEstimatorService());
    registerService(PNCounterService.SERVICE_NAME, new PNCounterService());
    registerService(CRDTReplicationMigrationService.SERVICE_NAME, new CRDTReplicationMigrationService());
    registerService(DistributedScheduledExecutorService.SERVICE_NAME, new DistributedScheduledExecutorService());
    registerService(MetricsService.SERVICE_NAME, new MetricsService(nodeEngine));
    registerCacheServiceIfAvailable();
    readServiceDescriptors();
}
Also used : DistributedDurableExecutorService(com.hazelcast.durableexecutor.impl.DistributedDurableExecutorService) XAService(com.hazelcast.transaction.impl.xa.XAService) CRDTReplicationMigrationService(com.hazelcast.internal.crdt.CRDTReplicationMigrationService) MetricsService(com.hazelcast.internal.metrics.impl.MetricsService) MultiMapService(com.hazelcast.multimap.impl.MultiMapService) SetService(com.hazelcast.collection.impl.set.SetService) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) QueueService(com.hazelcast.collection.impl.queue.QueueService) FlakeIdGeneratorService(com.hazelcast.flakeidgen.impl.FlakeIdGeneratorService) ListService(com.hazelcast.collection.impl.list.ListService) TopicService(com.hazelcast.topic.impl.TopicService) ReliableTopicService(com.hazelcast.topic.impl.reliable.ReliableTopicService) DistributedScheduledExecutorService(com.hazelcast.scheduledexecutor.impl.DistributedScheduledExecutorService) ReliableTopicService(com.hazelcast.topic.impl.reliable.ReliableTopicService) LockSupportServiceImpl(com.hazelcast.internal.locksupport.LockSupportServiceImpl) DistributedExecutorService(com.hazelcast.executor.impl.DistributedExecutorService) RingbufferService(com.hazelcast.ringbuffer.impl.RingbufferService) MultiMapService(com.hazelcast.multimap.impl.MultiMapService) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) MapService(com.hazelcast.map.impl.MapService) PNCounterService(com.hazelcast.internal.crdt.pncounter.PNCounterService) CardinalityEstimatorService(com.hazelcast.cardinality.impl.CardinalityEstimatorService)

Example 3 with LockSupportServiceImpl

use of com.hazelcast.internal.locksupport.LockSupportServiceImpl 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 4 with LockSupportServiceImpl

use of com.hazelcast.internal.locksupport.LockSupportServiceImpl 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

LockSupportServiceImpl (com.hazelcast.internal.locksupport.LockSupportServiceImpl)4 LockStoreContainer (com.hazelcast.internal.locksupport.LockStoreContainer)3 LockStoreImpl (com.hazelcast.internal.locksupport.LockStoreImpl)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 CardinalityEstimatorService (com.hazelcast.cardinality.impl.CardinalityEstimatorService)1