Search in sources :

Example 1 with MemoryInfoAccessor

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

Example 2 with MemoryInfoAccessor

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);
    }
}
Also used : EvictionChecker(com.hazelcast.map.impl.eviction.EvictionChecker) IPartitionService(com.hazelcast.spi.partition.IPartitionService) EvictorImpl(com.hazelcast.map.impl.eviction.EvictorImpl) RuntimeMemoryInfoAccessor(com.hazelcast.util.RuntimeMemoryInfoAccessor) MemoryInfoAccessor(com.hazelcast.util.MemoryInfoAccessor) MapEvictionPolicy(com.hazelcast.map.eviction.MapEvictionPolicy)

Aggregations

MapEvictionPolicy (com.hazelcast.map.eviction.MapEvictionPolicy)2 EvictionChecker (com.hazelcast.map.impl.eviction.EvictionChecker)2 IPartitionService (com.hazelcast.spi.partition.IPartitionService)2 MemoryInfoAccessor (com.hazelcast.util.MemoryInfoAccessor)2 MapContainer (com.hazelcast.map.impl.MapContainer)1 MapService (com.hazelcast.map.impl.MapService)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1 Evictor (com.hazelcast.map.impl.eviction.Evictor)1 EvictorImpl (com.hazelcast.map.impl.eviction.EvictorImpl)1 MapProxyImpl (com.hazelcast.map.impl.proxy.MapProxyImpl)1 RuntimeMemoryInfoAccessor (com.hazelcast.util.RuntimeMemoryInfoAccessor)1