Search in sources :

Example 1 with IPartitionService

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

the class CardinalityEstimatorService method getPartitionId.

private int getPartitionId(String name) {
    IPartitionService partitionService = nodeEngine.getPartitionService();
    String partitionKey = getPartitionKey(name);
    return partitionService.getPartitionId(partitionKey);
}
Also used : IPartitionService(com.hazelcast.internal.partition.IPartitionService)

Example 2 with IPartitionService

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

the class LocalLockCleanupOperation method shouldBackup.

@Override
public boolean shouldBackup() {
    final NodeEngine nodeEngine = getNodeEngine();
    IPartitionService partitionService = nodeEngine.getPartitionService();
    IPartition partition = partitionService.getPartition(getPartitionId());
    return partition.isLocal() && Boolean.TRUE.equals(response);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) IPartitionService(com.hazelcast.internal.partition.IPartitionService) IPartition(com.hazelcast.internal.partition.IPartition)

Example 3 with IPartitionService

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

the class LoadAllOperation method selectThisPartitionsKeys.

/**
 * Filters the {@link #keys} list for keys matching the partition on
 * which this operation is executed.
 *
 * @return the filtered key list
 */
private List<Data> selectThisPartitionsKeys() {
    final IPartitionService partitionService = mapServiceContext.getNodeEngine().getPartitionService();
    final int partitionId = getPartitionId();
    List<Data> dataKeys = null;
    for (Data key : keys) {
        if (partitionId == partitionService.getPartitionId(key)) {
            if (dataKeys == null) {
                dataKeys = new ArrayList<>(keys.size());
            }
            dataKeys.add(key);
        }
    }
    if (dataKeys == null) {
        return Collections.emptyList();
    }
    return dataKeys;
}
Also used : IPartitionService(com.hazelcast.internal.partition.IPartitionService) Data(com.hazelcast.internal.serialization.Data)

Example 4 with IPartitionService

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

the class MapGetInvalidationMetaDataOperation method getOwnedPartitions.

private List<Integer> getOwnedPartitions() {
    IPartitionService partitionService = getNodeEngine().getPartitionService();
    Map<Address, List<Integer>> memberPartitionsMap = partitionService.getMemberPartitionsMap();
    List<Integer> ownedPartitions = memberPartitionsMap.get(getNodeEngine().getThisAddress());
    return ownedPartitions == null ? Collections.emptyList() : ownedPartitions;
}
Also used : Address(com.hazelcast.cluster.Address) IPartitionService(com.hazelcast.internal.partition.IPartitionService) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with IPartitionService

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

the class MapChunk method entryCountOnThisNode.

private long entryCountOnThisNode(MapContainer mapContainer) {
    int replicaIndex = getReplicaIndex();
    long owned = 0;
    MapServiceContext mapServiceContext = mapContainer.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) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

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