use of com.hazelcast.concurrent.lock.LockServiceImpl 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);
LockServiceImpl lockService = nodeEngine.getService(LockService.SERVICE_NAME);
int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
for (int i = 0; i < partitionCount; i++) {
LockStoreContainer lockContainer = lockService.getLockContainer(i);
assertEquals("LockStores should be empty", 0, lockContainer.getLockStores().size());
}
}
use of com.hazelcast.concurrent.lock.LockServiceImpl 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(LockService.SERVICE_NAME, new LockServiceImpl(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(AtomicLongService.SERVICE_NAME, new AtomicLongService());
registerService(AtomicReferenceService.SERVICE_NAME, new AtomicReferenceService());
registerService(CountDownLatchService.SERVICE_NAME, new CountDownLatchService());
registerService(SemaphoreService.SERVICE_NAME, new SemaphoreService(nodeEngine));
registerService(IdGeneratorService.SERVICE_NAME, new IdGeneratorService(nodeEngine));
registerService(MapReduceService.SERVICE_NAME, new MapReduceService(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(DistributedScheduledExecutorService.SERVICE_NAME, new DistributedScheduledExecutorService());
registerCacheServiceIfAvailable();
readServiceDescriptors();
}
use of com.hazelcast.concurrent.lock.LockServiceImpl in project hazelcast by hazelcast.
the class LockReplicationOperation method run.
@Override
public void run() {
LockServiceImpl lockService = getService();
LockStoreContainer container = lockService.getLockContainer(getPartitionId());
for (LockStoreImpl ls : locks) {
container.put(ls);
}
}
use of com.hazelcast.concurrent.lock.LockServiceImpl in project hazelcast by hazelcast.
the class MultiMapLockTest method lockStoreShouldBeRemoved_whenMultimapIsDestroyed.
/**
* See issue #4888
*/
@Test
public void lockStoreShouldBeRemoved_whenMultimapIsDestroyed() {
HazelcastInstance hz = createHazelcastInstance();
MultiMap multiMap = hz.getMultiMap(randomName());
for (int i = 0; i < 1000; i++) {
multiMap.lock(i);
}
multiMap.destroy();
NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
LockServiceImpl lockService = nodeEngine.getService(LockService.SERVICE_NAME);
int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
for (int i = 0; i < partitionCount; i++) {
LockStoreContainer lockContainer = lockService.getLockContainer(i);
Collection<LockStoreImpl> lockStores = lockContainer.getLockStores();
assertEquals("LockStores should be empty: " + lockStores, 0, lockStores.size());
}
}
use of com.hazelcast.concurrent.lock.LockServiceImpl 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));
}
Aggregations