Search in sources :

Example 1 with IPartition

use of com.hazelcast.spi.partition.IPartition in project hazelcast by hazelcast.

the class GetPartitionsMessageTask method call.

protected Object call() {
    InternalPartitionService service = getService(InternalPartitionService.SERVICE_NAME);
    service.firstArrangement();
    Map<Address, List<Integer>> partitionsMap = new HashMap<Address, List<Integer>>();
    for (IPartition partition : service.getPartitions()) {
        Address owner = partition.getOwnerOrNull();
        if (owner == null) {
            partitionsMap.clear();
            return ClientGetPartitionsCodec.encodeResponse(partitionsMap.entrySet());
        }
        List<Integer> indexes = partitionsMap.get(owner);
        if (indexes == null) {
            indexes = new LinkedList<Integer>();
            partitionsMap.put(owner, indexes);
        }
        indexes.add(partition.getPartitionId());
    }
    return ClientGetPartitionsCodec.encodeResponse(partitionsMap.entrySet());
}
Also used : Address(com.hazelcast.nio.Address) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) HashMap(java.util.HashMap) List(java.util.List) LinkedList(java.util.LinkedList) IPartition(com.hazelcast.spi.partition.IPartition)

Example 2 with IPartition

use of com.hazelcast.spi.partition.IPartition 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 3 with IPartition

use of com.hazelcast.spi.partition.IPartition in project hazelcast by hazelcast.

the class TimedMemberStateFactory method createMemberState.

private void createMemberState(TimedMemberState timedMemberState, MemberStateImpl memberState, Collection<StatisticsAwareService> services) {
    Node node = instance.node;
    HashSet<ClientEndPointDTO> serializableClientEndPoints = new HashSet<ClientEndPointDTO>();
    for (Client client : instance.node.clientEngine.getClients()) {
        serializableClientEndPoints.add(new ClientEndPointDTO(client));
    }
    memberState.setClients(serializableClientEndPoints);
    Address thisAddress = node.getThisAddress();
    memberState.setAddress(thisAddress.getHost() + ":" + thisAddress.getPort());
    TimedMemberStateFactoryHelper.registerJMXBeans(instance, memberState);
    MemberPartitionStateImpl memberPartitionState = (MemberPartitionStateImpl) memberState.getMemberPartitionState();
    InternalPartitionService partitionService = node.getPartitionService();
    IPartition[] partitions = partitionService.getPartitions();
    List<Integer> partitionList = memberPartitionState.getPartitions();
    for (IPartition partition : partitions) {
        if (partition.isLocal()) {
            partitionList.add(partition.getPartitionId());
        }
    }
    memberPartitionState.setMigrationQueueSize(partitionService.getMigrationQueueSize());
    memberPartitionState.setMemberStateSafe(memberStateSafe);
    memberState.setLocalMemoryStats(getMemoryStats());
    memberState.setOperationStats(getOperationStats());
    TimedMemberStateFactoryHelper.createRuntimeProps(memberState);
    createMemState(timedMemberState, memberState, services);
    createNodeState(memberState);
    createHotRestartState(memberState);
    createClusterHotRestartStatus(memberState);
    createWanSyncState(memberState);
}
Also used : Address(com.hazelcast.nio.Address) ClientEndPointDTO(com.hazelcast.internal.management.dto.ClientEndPointDTO) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) Node(com.hazelcast.instance.Node) MemberPartitionStateImpl(com.hazelcast.monitor.impl.MemberPartitionStateImpl) Client(com.hazelcast.core.Client) IPartition(com.hazelcast.spi.partition.IPartition) HashSet(java.util.HashSet)

Example 4 with IPartition

use of com.hazelcast.spi.partition.IPartition in project hazelcast by hazelcast.

the class LocalMapStatsProvider method getReplicaAddress.

/**
     * Gets replica address. Waits if necessary.
     *
     * @see #waitForReplicaAddress
     */
private Address getReplicaAddress(int partitionId, int replicaNumber, int backupCount) {
    IPartition partition = partitionService.getPartition(partitionId);
    Address replicaAddress = partition.getReplicaAddress(replicaNumber);
    if (replicaAddress == null) {
        replicaAddress = waitForReplicaAddress(replicaNumber, partition, backupCount);
    }
    return replicaAddress;
}
Also used : Address(com.hazelcast.nio.Address) IPartition(com.hazelcast.spi.partition.IPartition)

Example 5 with IPartition

use of com.hazelcast.spi.partition.IPartition in project hazelcast by hazelcast.

the class AccumulatorConsumerOperation method isLocal.

private boolean isLocal() {
    NodeEngine nodeEngine = getNodeEngine();
    IPartitionService partitionService = nodeEngine.getPartitionService();
    IPartition partition = partitionService.getPartition(getPartitionId());
    return partition.isLocal();
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) IPartitionService(com.hazelcast.spi.partition.IPartitionService) IPartition(com.hazelcast.spi.partition.IPartition)

Aggregations

IPartition (com.hazelcast.spi.partition.IPartition)22 Address (com.hazelcast.nio.Address)13 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)6 NodeEngine (com.hazelcast.spi.NodeEngine)6 IPartitionService (com.hazelcast.spi.partition.IPartitionService)5 Node (com.hazelcast.instance.Node)4 HashSet (java.util.HashSet)4 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 HashMap (java.util.HashMap)3 List (java.util.List)3 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)2 AbstractPartitionLostListenerTest (com.hazelcast.partition.AbstractPartitionLostListenerTest)2 MigrationEndpoint (com.hazelcast.spi.partition.MigrationEndpoint)2 AssertTask (com.hazelcast.test.AssertTask)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 LinkedList (java.util.LinkedList)2 Test (org.junit.Test)2 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)1 CachePartitionLostEvent (com.hazelcast.cache.impl.event.CachePartitionLostEvent)1