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