use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.
the class WanReplicationConfigurationTest method initInstanceAndMapContainer.
private void initInstanceAndMapContainer(String name) {
HazelcastInstance instance = factory.newHazelcastInstance(getConfig());
MapProxyImpl mapProxy = (MapProxyImpl) instance.getMap(name);
MapService mapService = (MapService) mapProxy.getService();
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
mapContainer = mapServiceContext.getMapContainer(name);
}
use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.
the class MapIndexJsonTest method getIndexOfAttributeForMap.
protected static List<Index> getIndexOfAttributeForMap(HazelcastInstance instance, String mapName, String attribute) {
Node node = getNode(instance);
MapService service = node.nodeEngine.getService(MapService.SERVICE_NAME);
MapServiceContext mapServiceContext = service.getMapServiceContext();
MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
List<Index> result = new ArrayList<>();
for (int partitionId : mapServiceContext.getOrInitCachedMemberPartitions()) {
Indexes indexes = mapContainer.getIndexes(partitionId);
result.add(indexes.getIndex(attribute));
}
return result;
}
use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.
the class MapBackupAccessor method getRecord.
public Record getRecord(K key) {
IPartition partition = getPartitionForKey(key);
HazelcastInstance hz = getHazelcastInstance(partition);
Node node = getNode(hz);
SerializationService serializationService = node.getSerializationService();
MapService mapService = node.getNodeEngine().getService(MapService.SERVICE_NAME);
MapServiceContext context = mapService.getMapServiceContext();
int partitionId = partition.getPartitionId();
PartitionContainer partitionContainer = context.getPartitionContainer(partitionId);
return runOnPartitionThread(hz, new GetRecordCallable(serializationService, partitionContainer, key), partitionId);
}
use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.
the class DynamicMapConfigTest method isEvictionEnabled.
private boolean isEvictionEnabled(IMap map) {
MapProxyImpl mapProxy = (MapProxyImpl) map;
MapService mapService = (MapService) mapProxy.getService();
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
MapContainer mapContainer = mapServiceContext.getMapContainer(map.getName());
EvictionPolicy evictionPolicy = mapContainer.getMapConfig().getEvictionConfig().getEvictionPolicy();
return evictionPolicy != NONE;
}
use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.
the class EvictionMaxSizePolicyTest method setMockRuntimeMemoryInfoAccessor.
public static void setMockRuntimeMemoryInfoAccessor(IMap map, final long totalMemoryMB, final long freeMemoryMB, final long maxMemoryMB) {
final MapProxyImpl mapProxy = (MapProxyImpl) map;
final MapService mapService = (MapService) mapProxy.getService();
final MapServiceContext mapServiceContext = mapService.getMapServiceContext();
MemoryInfoAccessor memoryInfoAccessor = new MemoryInfoAccessor() {
@Override
public long getTotalMemory() {
return MEGABYTES.toBytes(totalMemoryMB);
}
@Override
public long getFreeMemory() {
return MEGABYTES.toBytes(freeMemoryMB);
}
@Override
public long getMaxMemory() {
return MEGABYTES.toBytes(maxMemoryMB);
}
};
MapContainer mapContainer = mapServiceContext.getMapContainer(map.getName());
EvictionChecker evictionChecker = new EvictionChecker(memoryInfoAccessor, mapServiceContext);
IPartitionService partitionService = mapServiceContext.getNodeEngine().getPartitionService();
Evictor evictor = new TestEvictor(LRUEvictionPolicyComparator.INSTANCE, evictionChecker, partitionService);
mapContainer.setEvictor(evictor);
}
Aggregations