Search in sources :

Example 36 with IPartitionService

use of com.hazelcast.internal.partition.IPartitionService in project hazelcast by hazelcast.

the class Accessors method getAllIndexes.

/**
 * Obtains a list of {@link Indexes} for the given map local to the node
 * associated with it.
 * <p>
 * There may be more than one indexes instance associated with a map if its
 * indexes are partitioned.
 *
 * @param map the map to obtain the indexes for.
 * @return the obtained indexes list.
 */
public static List<Indexes> getAllIndexes(IMap map) {
    MapProxyImpl mapProxy = (MapProxyImpl) map;
    String mapName = mapProxy.getName();
    NodeEngine nodeEngine = mapProxy.getNodeEngine();
    IPartitionService partitionService = nodeEngine.getPartitionService();
    MapService mapService = nodeEngine.getService(MapService.SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
    Indexes maybeGlobalIndexes = mapContainer.getIndexes();
    if (maybeGlobalIndexes != null) {
        return Collections.singletonList(maybeGlobalIndexes);
    }
    PartitionContainer[] partitionContainers = mapServiceContext.getPartitionContainers();
    List<Indexes> allIndexes = new ArrayList<>();
    for (PartitionContainer partitionContainer : partitionContainers) {
        IPartition partition = partitionService.getPartition(partitionContainer.getPartitionId());
        if (!partition.isLocal()) {
            continue;
        }
        Indexes partitionIndexes = partitionContainer.getIndexes().get(mapName);
        if (partitionIndexes == null) {
            continue;
        }
        assert !partitionIndexes.isGlobal();
        allIndexes.add(partitionIndexes);
    }
    return allIndexes;
}
Also used : PartitionContainer(com.hazelcast.map.impl.PartitionContainer) IPartitionService(com.hazelcast.internal.partition.IPartitionService) ArrayList(java.util.ArrayList) Indexes(com.hazelcast.query.impl.Indexes) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapContainer(com.hazelcast.map.impl.MapContainer) NodeEngine(com.hazelcast.spi.impl.NodeEngine) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) MapService(com.hazelcast.map.impl.MapService) IPartition(com.hazelcast.internal.partition.IPartition)

Aggregations

IPartitionService (com.hazelcast.internal.partition.IPartitionService)36 Data (com.hazelcast.internal.serialization.Data)10 NodeEngine (com.hazelcast.spi.impl.NodeEngine)10 Address (com.hazelcast.cluster.Address)8 List (java.util.List)7 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)6 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)6 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)5 IPartition (com.hazelcast.internal.partition.IPartition)4 PartitionIdSet (com.hazelcast.internal.util.collection.PartitionIdSet)4 MapService (com.hazelcast.map.impl.MapService)4 ClusterService (com.hazelcast.internal.cluster.ClusterService)3 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)3 ICacheService (com.hazelcast.cache.impl.ICacheService)2 Connection (com.hazelcast.internal.nio.Connection)2 JobConfig (com.hazelcast.jet.config.JobConfig)2 ProcessorSupplier (com.hazelcast.jet.core.ProcessorSupplier)2 JetServiceBackend (com.hazelcast.jet.impl.JetServiceBackend)2