use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.
the class MapMergePolicyQuickTest method testPutIfAbsentMapMergePolicy.
@Test
public void testPutIfAbsentMapMergePolicy() {
HazelcastInstance instance = createHazelcastInstance(getConfig());
String name = randomString();
IMap<String, String> map = instance.getMap(name);
MapServiceContext mapServiceContext = getMapServiceContext(instance);
Data dataKey = mapServiceContext.toData("key");
RecordStore recordStore = mapServiceContext.getRecordStore(getPartitionId(instance, "key"), name);
MapMergePolicy mergePolicy = mapServiceContext.getMergePolicyProvider().getMergePolicy(PutIfAbsentMapMergePolicy.class.getName());
SimpleEntryView<String, String> initialEntry = new SimpleEntryView<String, String>("key", "value1");
recordStore.merge(dataKey, initialEntry, mergePolicy);
SimpleEntryView<String, String> mergingEntry = new SimpleEntryView<String, String>("key", "value2");
recordStore.merge(dataKey, mergingEntry, mergePolicy);
assertEquals("value1", map.get("key"));
}
use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.
the class NearCacheTestSupport method getNearCache.
protected NearCache getNearCache(String mapName, HazelcastInstance instance) {
NodeEngineImpl nodeEngine = getNode(instance).nodeEngine;
MapService service = nodeEngine.getService(SERVICE_NAME);
MapServiceContext mapServiceContext = service.getMapServiceContext();
MapNearCacheManager mapNearCacheManager = mapServiceContext.getMapNearCacheManager();
NearCacheConfig nearCacheConfig = nodeEngine.getConfig().getMapConfig(mapName).getNearCacheConfig();
return mapNearCacheManager.getOrCreateNearCache(mapName, nearCacheConfig);
}
use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.
the class InvalidationMetadataDistortionTest method distortRandomPartitionUuid.
private void distortRandomPartitionUuid(HazelcastInstance member) {
NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(member);
int partitionCount = nodeEngineImpl.getPartitionService().getPartitionCount();
int partitionId = getInt(partitionCount);
MapService mapService = nodeEngineImpl.getService(SERVICE_NAME);
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
MapNearCacheManager mapNearCacheManager = mapServiceContext.getMapNearCacheManager();
Invalidator invalidator = mapNearCacheManager.getInvalidator();
MetaDataGenerator metaDataGenerator = invalidator.getMetaDataGenerator();
metaDataGenerator.setUuid(partitionId, UuidUtil.newSecureUUID());
}
use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.
the class ContainsValueOperationTest method executeOperation.
protected InternalCompletableFuture<Object> executeOperation(Map map, String key, int value) {
int partitionId = getNode(member1).getPartitionService().getPartitionId(key);
MapProxyImpl mapProxy = (MapProxyImpl) map;
MapServiceContext mapServiceContext = ((MapService) mapProxy.getService()).getMapServiceContext();
MapOperationProvider operationProvider = mapServiceContext.getMapOperationProvider(mapProxy.getName());
OperationFactory operationFactory = operationProvider.createContainsValueOperationFactory(mapProxy.getName(), mapServiceContext.toData(value));
Operation operation = operationFactory.createOperation();
InternalOperationService operationService = getOperationService(member1);
return operationService.createInvocationBuilder(MapService.SERVICE_NAME, operation, partitionId).invoke();
}
use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.
the class MapStoreWriteBehindTest method writeBehindQueueSize.
private int writeBehindQueueSize(HazelcastInstance node, String mapName) {
int size = 0;
final NodeEngineImpl nodeEngine = getNode(node).getNodeEngine();
MapService mapService = nodeEngine.getService(MapService.SERVICE_NAME);
final MapServiceContext mapServiceContext = mapService.getMapServiceContext();
final int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
for (int i = 0; i < partitionCount; i++) {
final RecordStore recordStore = mapServiceContext.getExistingRecordStore(i, mapName);
if (recordStore == null) {
continue;
}
final MapDataStore mapDataStore = recordStore.getMapDataStore();
size += ((WriteBehindStore) mapDataStore).getWriteBehindQueue().size();
}
return size;
}
Aggregations