use of com.hazelcast.map.impl.MapService in project hazelcast by hazelcast.
the class MergePolicySerializationTest method testIssue2665.
@Test
public void testIssue2665() {
String name = randomString();
String serviceName = "hz:impl:mapService";
HazelcastInstance instance = createHazelcastInstance(getConfig());
IMap<String, MyObject> map = instance.getMap(name);
MyObject myObjectExisting = new MyObject();
map.put("key", myObjectExisting);
NodeEngineImpl nodeEngine = HazelcastTestSupport.getNode(instance).getNodeEngine();
MapService mapService = nodeEngine.getService(serviceName);
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
int partitionId = nodeEngine.getPartitionService().getPartitionId("key");
Data dataKey = mapServiceContext.toData("key");
RecordStore recordStore = mapServiceContext.getRecordStore(partitionId, name);
MapMergePolicy mergePolicy = mapServiceContext.getMergePolicyProvider().getMergePolicy(PutIfAbsentMapMergePolicy.class.getName());
EntryView<String, MyObject> mergingEntryView = new SimpleEntryView<String, MyObject>("key", new MyObject());
recordStore.merge(dataKey, mergingEntryView, mergePolicy);
int deSerializedCount = MyObject.deserializedCount;
assertEquals(0, deSerializedCount);
}
use of com.hazelcast.map.impl.MapService in project hazelcast by hazelcast.
the class MapPartitionLostListenerTest method test_allPartitionLostListenersInvoked.
@Test
public void test_allPartitionLostListenersInvoked() {
List<HazelcastInstance> instances = getCreatedInstancesShuffledAfterWarmedUp(2);
HazelcastInstance instance1 = instances.get(0);
HazelcastInstance instance2 = instances.get(0);
final TestEventCollectingMapPartitionLostListener listener1 = new TestEventCollectingMapPartitionLostListener(0);
final TestEventCollectingMapPartitionLostListener listener2 = new TestEventCollectingMapPartitionLostListener(0);
instance1.getMap(getIthMapName(0)).addPartitionLostListener(listener1);
instance2.getMap(getIthMapName(0)).addPartitionLostListener(listener2);
final IPartitionLostEvent internalEvent = new IPartitionLostEvent(1, 0, null);
MapService mapService = getNode(instance1).getNodeEngine().getService(MapService.SERVICE_NAME);
mapService.onPartitionLost(internalEvent);
assertEventEventually(listener1, internalEvent);
assertEventEventually(listener2, internalEvent);
}
use of com.hazelcast.map.impl.MapService in project hazelcast by hazelcast.
the class WriteBehindOnBackupsTest method writeBehindQueueSize.
public static 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();
if (mapDataStore instanceof WriteBehindStore) {
size += ((WriteBehindStore) mapDataStore).getWriteBehindQueue().size();
}
}
return size;
}
use of com.hazelcast.map.impl.MapService in project hazelcast by hazelcast.
the class WanReplicationTest method getOperationProvider.
private MapOperationProvider getOperationProvider(Map map) {
MapProxyImpl mapProxy = (MapProxyImpl) map;
MapServiceContext mapServiceContext = ((MapService) mapProxy.getService()).getMapServiceContext();
return mapServiceContext.getMapOperationProvider(mapProxy.getName());
}
use of com.hazelcast.map.impl.MapService in project hazelcast by hazelcast.
the class DynamicMapConfigTest method isRecordStoreExpirable.
private boolean isRecordStoreExpirable(IMap map) {
MapProxyImpl mapProxy = (MapProxyImpl) map;
MapService mapService = (MapService) mapProxy.getService();
MapServiceContext mapServiceContext = (MapServiceContext) mapService.getMapServiceContext();
PartitionContainer container = mapServiceContext.getPartitionContainer(0);
RecordStore recordStore = container.getExistingRecordStore(map.getName());
return recordStore.isExpirable();
}
Aggregations