use of com.hazelcast.internal.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());
EvictionChecker evictionChecker = new EvictionChecker(memoryInfoAccessor, mapServiceContext);
IPartitionService partitionService = mapServiceContext.getNodeEngine().getPartitionService();
Evictor evictor = new TestEvictor(LRUEvictionPolicyComparator.INSTANCE, evictionChecker, partitionService);
mapContainer.setEvictor(evictor);
}
Aggregations