use of com.hazelcast.util.MemoryInfoAccessor 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());
MapEvictionPolicy mapEvictionPolicy = mapContainer.getMapConfig().getMapEvictionPolicy();
EvictionChecker evictionChecker = new EvictionChecker(memoryInfoAccessor, mapServiceContext);
IPartitionService partitionService = mapServiceContext.getNodeEngine().getPartitionService();
Evictor evictor = new TestEvictor(mapEvictionPolicy, evictionChecker, partitionService);
mapContainer.setEvictor(evictor);
}
use of com.hazelcast.util.MemoryInfoAccessor in project hazelcast by hazelcast.
the class MapContainer method initEvictor.
// this method is overridden.
public void initEvictor() {
MapEvictionPolicy mapEvictionPolicy = mapConfig.getMapEvictionPolicy();
if (mapEvictionPolicy == null) {
evictor = NULL_EVICTOR;
} else {
MemoryInfoAccessor memoryInfoAccessor = getMemoryInfoAccessor();
EvictionChecker evictionChecker = new EvictionChecker(memoryInfoAccessor, mapServiceContext);
IPartitionService partitionService = mapServiceContext.getNodeEngine().getPartitionService();
evictor = new EvictorImpl(mapEvictionPolicy, evictionChecker, partitionService);
}
}
Aggregations