Search in sources :

Example 86 with MapServiceContext

use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.

the class WanReplicationTest method getOperationProvider.

private MapOperationProvider getOperationProvider(Map map) {
    MapProxyImpl mapProxy = (MapProxyImpl) map;
    MapServiceContext mapServiceContext = ((MapService) mapProxy.getService()).getMapServiceContext();
    return mapServiceContext.getMapOperationProvider(mapProxy.getName());
}
Also used : MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 87 with MapServiceContext

use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.

the class MapGetInvalidationMetaDataOperation method getPartitionMetaDataGenerator.

private MetaDataGenerator getPartitionMetaDataGenerator() {
    MapService mapService = getService();
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    MapNearCacheManager nearCacheManager = mapServiceContext.getMapNearCacheManager();
    return nearCacheManager.getInvalidator().getMetaDataGenerator();
}
Also used : MapNearCacheManager(com.hazelcast.map.impl.nearcache.MapNearCacheManager) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 88 with MapServiceContext

use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.

the class MapReplicationStateHolder method entryCountOnThisNode.

// owned or backup
private long entryCountOnThisNode(MapContainer mapContainer) {
    int replicaIndex = operation.getReplicaIndex();
    long owned = 0;
    if (mapContainer.getEvictor() != Evictor.NULL_EVICTOR && PER_NODE == mapContainer.getMapConfig().getEvictionConfig().getMaxSizePolicy()) {
        MapService mapService = operation.getService();
        MapServiceContext mapServiceContext = mapService.getMapServiceContext();
        IPartitionService partitionService = mapServiceContext.getNodeEngine().getPartitionService();
        int partitionCount = partitionService.getPartitionCount();
        for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
            if (replicaIndex == 0 ? partitionService.isPartitionOwner(partitionId) : !partitionService.isPartitionOwner(partitionId)) {
                RecordStore store = mapServiceContext.getExistingRecordStore(partitionId, mapContainer.getName());
                if (store != null) {
                    owned += store.size();
                }
            }
        }
    }
    return owned;
}
Also used : IPartitionService(com.hazelcast.internal.partition.IPartitionService) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 89 with MapServiceContext

use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.

the class PartitionWideEntryWithPredicateOperationFactory method tryToObtainKeysFromIndexes.

/**
 * Attempts to get keys by running an index query. This method may return
 * {@code null} if there is an ongoing migration, which means that it is not
 * safe to return results from a non-partition thread. The caller must then
 * run a partition query to obtain the results.
 *
 * @param nodeEngine nodeEngine of this cluster node
 * @return the set of keys or {@code null} if we failed to fetch the keys
 * because of ongoing migrations
 */
private Set<Data> tryToObtainKeysFromIndexes(NodeEngine nodeEngine) {
    // Do not use index in this case, because it requires full-table-scan.
    if (predicate == Predicates.alwaysTrue()) {
        return null;
    }
    MapService mapService = nodeEngine.getService(SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    MapContainer mapContainer = mapServiceContext.getMapContainer(name);
    if (!mapContainer.shouldUseGlobalIndex()) {
        return null;
    }
    QueryRunner runner = mapServiceContext.getMapQueryRunner(name);
    Query query = Query.of().mapName(name).predicate(predicate).iterationType(IterationType.KEY).build();
    final QueryResult result = (QueryResult) runner.runIndexQueryOnOwnedPartitions(query);
    if (result.getPartitionIds() == null) {
        // failed to run query because of ongoing migrations
        return null;
    }
    final Builder<Data> setBuilder = InflatableSet.newBuilder(result.size());
    for (QueryResultRow row : result.getRows()) {
        setBuilder.add(row.getKey());
    }
    return setBuilder.build();
}
Also used : QueryResult(com.hazelcast.map.impl.query.QueryResult) Query(com.hazelcast.map.impl.query.Query) QueryResultRow(com.hazelcast.map.impl.query.QueryResultRow) Data(com.hazelcast.internal.serialization.Data) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapContainer(com.hazelcast.map.impl.MapContainer) QueryRunner(com.hazelcast.map.impl.query.QueryRunner)

Example 90 with MapServiceContext

use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.

the class MapReplicationOperation method getRecordStore.

public RecordStore getRecordStore(String mapName) {
    final boolean skipLoadingOnRecordStoreCreate = true;
    MapService mapService = getService();
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    return mapServiceContext.getRecordStore(getPartitionId(), mapName, skipLoadingOnRecordStoreCreate);
}
Also used : MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

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