Search in sources :

Example 26 with InternalPartitionService

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

the class TestPartitionUtils method getReplicaAddresses.

public static List<Address> getReplicaAddresses(Node node, int partitionId) {
    List<Address> replicaAddresses = new ArrayList<Address>();
    InternalPartitionService partitionService = node.getPartitionService();
    InternalPartition partition = partitionService.getPartition(partitionId);
    for (int i = 0; i < MAX_REPLICA_COUNT; i++) {
        replicaAddresses.add(partition.getReplicaAddress(i));
    }
    return replicaAddresses;
}
Also used : Address(com.hazelcast.nio.Address) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) ArrayList(java.util.ArrayList) InternalPartition(com.hazelcast.internal.partition.InternalPartition)

Example 27 with InternalPartitionService

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

the class HazelcastTestSupport method checkPartitionCountGreaterOrEqualMemberCount.

private static void checkPartitionCountGreaterOrEqualMemberCount(HazelcastInstance instance) {
    Cluster cluster = instance.getCluster();
    int memberCount = cluster.getMembers().size();
    InternalPartitionService internalPartitionService = getPartitionService(instance);
    int partitionCount = internalPartitionService.getPartitionCount();
    if (partitionCount < memberCount) {
        throw new UnsupportedOperationException("Partition count should be equal or greater than member count!");
    }
}
Also used : InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) Cluster(com.hazelcast.core.Cluster)

Example 28 with InternalPartitionService

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

the class HazelcastTestSupport method isInstanceInSafeState.

public static boolean isInstanceInSafeState(HazelcastInstance instance) {
    Node node = TestUtil.getNode(instance);
    if (node == null) {
        return true;
    }
    InternalPartitionService ps = node.getPartitionService();
    return ps.isMemberStateSafe();
}
Also used : InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) Node(com.hazelcast.instance.Node)

Example 29 with InternalPartitionService

use of com.hazelcast.internal.partition.InternalPartitionService 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 = 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());
}
Also used : InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) IPartition(com.hazelcast.spi.partition.IPartition)

Example 30 with InternalPartitionService

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

the class SafeStateCheckOperation method run.

@Override
public void run() throws Exception {
    final InternalPartitionService service = getService();
    safe = service.isMemberStateSafe();
}
Also used : InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService)

Aggregations

InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)45 Address (com.hazelcast.nio.Address)11 HazelcastInstance (com.hazelcast.core.HazelcastInstance)10 Test (org.junit.Test)10 Node (com.hazelcast.instance.Node)9 ParallelTest (com.hazelcast.test.annotation.ParallelTest)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9 ArrayList (java.util.ArrayList)8 Config (com.hazelcast.config.Config)6 Data (com.hazelcast.nio.serialization.Data)6 IPartition (com.hazelcast.spi.partition.IPartition)6 HashMap (java.util.HashMap)6 InternalPartition (com.hazelcast.internal.partition.InternalPartition)5 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)5 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)5 List (java.util.List)5 Map (java.util.Map)5 ICacheService (com.hazelcast.cache.impl.ICacheService)4 ICacheRecordStore (com.hazelcast.cache.impl.ICacheRecordStore)3 CacheConfig (com.hazelcast.config.CacheConfig)3