Search in sources :

Example 21 with IPartitionService

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);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) IPartitionService(com.hazelcast.spi.partition.IPartitionService) IPartition(com.hazelcast.spi.partition.IPartition)

Example 22 with IPartitionService

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);
}
Also used : IPartitionService(com.hazelcast.spi.partition.IPartitionService) SerializationService(com.hazelcast.spi.serialization.SerializationService) Data(com.hazelcast.nio.serialization.Data) MigrationEndpoint(com.hazelcast.spi.partition.MigrationEndpoint)

Example 23 with IPartitionService

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;
}
Also used : IPartitionService(com.hazelcast.spi.partition.IPartitionService) Data(com.hazelcast.nio.serialization.Data) HashSet(java.util.HashSet)

Example 24 with IPartitionService

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();
        }
    }
}
Also used : IPartitionService(com.hazelcast.spi.partition.IPartitionService) HashMap(java.util.HashMap) Map(java.util.Map) MigrationEndpoint(com.hazelcast.spi.partition.MigrationEndpoint)

Example 25 with IPartitionService

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);
}
Also used : IPartitionService(com.hazelcast.spi.partition.IPartitionService) JsonObject(com.eclipsesource.json.JsonObject) RuntimeMXBean(java.lang.management.RuntimeMXBean)

Aggregations

IPartitionService (com.hazelcast.spi.partition.IPartitionService)48 Data (com.hazelcast.nio.serialization.Data)11 NodeEngine (com.hazelcast.spi.NodeEngine)11 Address (com.hazelcast.nio.Address)8 HashMap (java.util.HashMap)8 OperationService (com.hazelcast.spi.OperationService)7 MigrationEndpoint (com.hazelcast.spi.partition.MigrationEndpoint)7 Map (java.util.Map)7 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)5 IPartition (com.hazelcast.spi.partition.IPartition)5 MapService (com.hazelcast.map.impl.MapService)3 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 ICacheService (com.hazelcast.cache.impl.ICacheService)2 CacheRecord (com.hazelcast.cache.impl.record.CacheRecord)2 QueueReplicationOperation (com.hazelcast.collection.impl.queue.operations.QueueReplicationOperation)2 Member (com.hazelcast.core.Member)2 ClusterService (com.hazelcast.internal.cluster.ClusterService)2 MapEvictionPolicy (com.hazelcast.map.eviction.MapEvictionPolicy)2