Search in sources :

Example 1 with MemoryInfoAccessor

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);
}
Also used : EvictionChecker(com.hazelcast.map.impl.eviction.EvictionChecker) IPartitionService(com.hazelcast.internal.partition.IPartitionService) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) MemoryInfoAccessor(com.hazelcast.internal.util.MemoryInfoAccessor) MapService(com.hazelcast.map.impl.MapService) Evictor(com.hazelcast.map.impl.eviction.Evictor) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapContainer(com.hazelcast.map.impl.MapContainer)

Aggregations

IPartitionService (com.hazelcast.internal.partition.IPartitionService)1 MemoryInfoAccessor (com.hazelcast.internal.util.MemoryInfoAccessor)1 MapContainer (com.hazelcast.map.impl.MapContainer)1 MapService (com.hazelcast.map.impl.MapService)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1 EvictionChecker (com.hazelcast.map.impl.eviction.EvictionChecker)1 Evictor (com.hazelcast.map.impl.eviction.Evictor)1 MapProxyImpl (com.hazelcast.map.impl.proxy.MapProxyImpl)1