use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class SemaphoreDetachMemberOperation 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);
}
use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class QueueService method createLocalQueueStats.
/**
* Returns the local queue statistics for the queue with the given {@code name}. If this node is the owner of the queue,
* returned stats contain {@link LocalQueueStats#getOwnedItemCount()}, otherwise it contains
* {@link LocalQueueStats#getBackupItemCount()}.
*
* @param name the name of the queue for which the statistics are returned
* @return the statistics
*/
public LocalQueueStats createLocalQueueStats(String name) {
SerializationService serializationService = nodeEngine.getSerializationService();
IPartitionService partitionService = nodeEngine.getPartitionService();
Data keyData = serializationService.toData(name, StringPartitioningStrategy.INSTANCE);
int partitionId = partitionService.getPartitionId(keyData);
return createLocalQueueStats(name, partitionId);
}
use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class MapExecuteOnKeysMessageTask method getPartitions.
@Override
public Collection<Integer> getPartitions() {
IPartitionService partitionService = nodeEngine.getPartitionService();
int partitions = partitionService.getPartitionCount();
int capacity = Math.min(partitions, parameters.keys.size());
Set<Integer> partitionIds = new HashSet<Integer>(capacity);
Iterator<Data> iterator = parameters.keys.iterator();
while (iterator.hasNext() && partitionIds.size() < partitions) {
Data key = iterator.next();
partitionIds.add(partitionService.getPartitionId(key));
}
return partitionIds;
}
use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class CollectionService method clearCollectionsHavingLesserBackupCountThan.
private void clearCollectionsHavingLesserBackupCountThan(int partitionId, int thresholdReplicaIndex) {
Set<? extends Map.Entry<String, ? extends CollectionContainer>> entrySet = getContainerMap().entrySet();
Iterator<? extends Map.Entry<String, ? extends CollectionContainer>> iterator = entrySet.iterator();
IPartitionService partitionService = nodeEngine.getPartitionService();
while (iterator.hasNext()) {
Map.Entry<String, ? extends CollectionContainer> entry = iterator.next();
String name = entry.getKey();
CollectionContainer container = entry.getValue();
int containerPartitionId = partitionService.getPartitionId(StringPartitioningStrategy.getPartitionKey(name));
if (containerPartitionId != partitionId) {
continue;
}
if (thresholdReplicaIndex < 0 || thresholdReplicaIndex > container.getConfig().getTotalBackupCount()) {
container.destroy();
iterator.remove();
}
}
}
use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class ClusterPropsRequest method writeResponse.
@Override
public void writeResponse(ManagementCenterService mcs, JsonObject root) throws Exception {
Runtime runtime = Runtime.getRuntime();
RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
IPartitionService partitionService = mcs.getHazelcastInstance().node.getPartitionService();
JsonObject properties = new JsonObject();
properties.add("hazelcast.cl_version", mcs.getHazelcastInstance().node.getBuildInfo().getVersion());
properties.add("date.cl_startTime", Long.toString(runtimeMxBean.getStartTime()));
properties.add("seconds.cl_upTime", Long.toString(runtimeMxBean.getUptime()));
properties.add("memory.cl_freeMemory", Long.toString(runtime.freeMemory()));
properties.add("memory.cl_totalMemory", Long.toString(runtime.totalMemory()));
properties.add("memory.cl_maxMemory", Long.toString(runtime.maxMemory()));
properties.add("return.hasOngoingMigration", Boolean.toString(partitionService.hasOnGoingMigration()));
properties.add("data.cl_migrationTasksCount", Long.toString(partitionService.getMigrationQueueSize()));
root.add("result", properties);
}
Aggregations