Search in sources :

Example 56 with MapServiceContext

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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 57 with MapServiceContext

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;
}
Also used : Accessors.getNode(com.hazelcast.test.Accessors.getNode) Node(com.hazelcast.instance.impl.Node) ArrayList(java.util.ArrayList) Index(com.hazelcast.query.impl.Index) MapService(com.hazelcast.map.impl.MapService) Indexes(com.hazelcast.query.impl.Indexes) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapContainer(com.hazelcast.map.impl.MapContainer)

Example 58 with MapServiceContext

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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) PartitionContainer(com.hazelcast.map.impl.PartitionContainer) Node(com.hazelcast.instance.impl.Node) Accessors.getNode(com.hazelcast.test.Accessors.getNode) SerializationService(com.hazelcast.internal.serialization.SerializationService) MapService(com.hazelcast.map.impl.MapService) IPartition(com.hazelcast.internal.partition.IPartition) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 59 with MapServiceContext

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;
}
Also used : EvictionPolicy(com.hazelcast.config.EvictionPolicy) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapContainer(com.hazelcast.map.impl.MapContainer)

Example 60 with MapServiceContext

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);
}
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

MapServiceContext (com.hazelcast.map.impl.MapServiceContext)137 MapService (com.hazelcast.map.impl.MapService)111 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)34 MapNearCacheManager (com.hazelcast.map.impl.nearcache.MapNearCacheManager)29 Invalidator (com.hazelcast.internal.nearcache.impl.invalidation.Invalidator)25 MapContainer (com.hazelcast.map.impl.MapContainer)22 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)22 MetaDataGenerator (com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator)20 Accessors.getNodeEngineImpl (com.hazelcast.test.Accessors.getNodeEngineImpl)16 HazelcastInstance (com.hazelcast.core.HazelcastInstance)15 PartitionContainer (com.hazelcast.map.impl.PartitionContainer)15 NodeEngine (com.hazelcast.spi.impl.NodeEngine)14 MapProxyImpl (com.hazelcast.map.impl.proxy.MapProxyImpl)13 Node (com.hazelcast.instance.impl.Node)12 Data (com.hazelcast.internal.serialization.Data)11 Accessors.getNode (com.hazelcast.test.Accessors.getNode)10 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)9 Config (com.hazelcast.config.Config)8 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)8