use of com.hazelcast.internal.partition.IPartition in project hazelcast by hazelcast.
the class MapBackupAccessor method size.
@Override
public int size() {
InternalPartitionService partitionService = getNode(cluster[0]).getPartitionService();
IPartition[] partitions = partitionService.getPartitions();
int count = 0;
for (IPartition partition : partitions) {
Address replicaAddress = partition.getReplicaAddress(replicaIndex);
if (replicaAddress == null) {
continue;
}
HazelcastInstance hz = getInstanceWithAddress(replicaAddress);
NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
MapService mapService = nodeEngine.getService(MapService.SERVICE_NAME);
MapServiceContext context = mapService.getMapServiceContext();
int partitionId = partition.getPartitionId();
PartitionContainer partitionContainer = context.getPartitionContainer(partitionId);
count += runOnPartitionThread(hz, new SizeCallable(partitionContainer), partitionId);
}
return count;
}
use of com.hazelcast.internal.partition.IPartition 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;
}
use of com.hazelcast.internal.partition.IPartition in project hazelcast by hazelcast.
the class HazelcastTestSupport method getPartitionId.
// ##################################
// ########## partition ID ##########
// ##################################
/**
* Gets a partition ID owned by this particular member.
*/
public static int getPartitionId(HazelcastInstance hz) {
warmUpPartitions(hz);
InternalPartitionService partitionService = Accessors.getPartitionService(hz);
for (IPartition partition : partitionService.getPartitions()) {
if (partition.isLocal()) {
return partition.getPartitionId();
}
}
throw new RuntimeException("No local partitions are found for hz: " + hz.getName());
}
Aggregations