Search in sources :

Example 11 with PartitionTableView

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

the class FrozenPartitionTableTest method testPartitionTableIsHealedWhenClusterStateIsActiveAfter.

private void testPartitionTableIsHealedWhenClusterStateIsActiveAfter(final ClusterState clusterState) {
    final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
    HazelcastInstance[] instances = factory.newInstances();
    warmUpPartitions(instances);
    changeClusterStateEventually(instances[0], clusterState);
    List<HazelcastInstance> instancesList = new ArrayList<HazelcastInstance>(asList(instances));
    Collections.shuffle(instancesList);
    final HazelcastInstance instanceToShutdown = instancesList.remove(0);
    final Address addressToShutdown = getNode(instanceToShutdown).getThisAddress();
    instanceToShutdown.shutdown();
    for (HazelcastInstance instance : instancesList) {
        assertClusterSizeEventually(2, instance);
    }
    changeClusterStateEventually(instancesList.get(0), ClusterState.ACTIVE);
    waitAllForSafeState(instancesList);
    for (HazelcastInstance instance : instancesList) {
        PartitionTableView partitionTable = getPartitionTable(instance);
        for (int i = 0; i < partitionTable.length(); i++) {
            for (PartitionReplica replica : partitionTable.getReplicas(i)) {
                if (replica == null) {
                    continue;
                }
                assertNotEquals(addressToShutdown, replica.address());
            }
        }
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance) Address(com.hazelcast.cluster.Address) PartitionTableView(com.hazelcast.internal.partition.PartitionTableView) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) ArrayList(java.util.ArrayList) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory)

Example 12 with PartitionTableView

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

the class InternalPartitionServiceImplTest method test_setInitialState.

@Test
public void test_setInitialState() {
    InternalPartition[] partitions = new InternalPartition[partitionCount];
    for (int i = 0; i < partitionCount; i++) {
        PartitionReplica[] replicas = new PartitionReplica[MAX_REPLICA_COUNT];
        replicas[0] = PartitionReplica.from(localMember);
        partitions[i] = new ReadonlyInternalPartition(replicas, i, RandomPicker.getInt(1, 10));
    }
    partitionService.setInitialState(new PartitionTableView(partitions));
    for (int i = 0; i < partitionCount; i++) {
        assertTrue(partitionService.isPartitionOwner(i));
    }
    assertNotEquals(0, partitionService.getPartitionStateStamp());
}
Also used : PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) PartitionTableView(com.hazelcast.internal.partition.PartitionTableView) InternalPartition(com.hazelcast.internal.partition.InternalPartition) ReadonlyInternalPartition(com.hazelcast.internal.partition.ReadonlyInternalPartition) ReadonlyInternalPartition(com.hazelcast.internal.partition.ReadonlyInternalPartition) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

PartitionTableView (com.hazelcast.internal.partition.PartitionTableView)12 ArrayList (java.util.ArrayList)8 QuickTest (com.hazelcast.test.annotation.QuickTest)7 Test (org.junit.Test)7 Member (com.hazelcast.cluster.Member)6 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)6 PartitionReplica (com.hazelcast.internal.partition.PartitionReplica)5 HashMap (java.util.HashMap)5 Address (com.hazelcast.cluster.Address)4 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 HazelcastInstanceFactory.newHazelcastInstance (com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance)3 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)3 UUID (java.util.UUID)3 InternalPartition (com.hazelcast.internal.partition.InternalPartition)2 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)2 ReadonlyInternalPartition (com.hazelcast.internal.partition.ReadonlyInternalPartition)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)1 ClientAddClusterViewListenerCodec (com.hazelcast.client.impl.protocol.codec.ClientAddClusterViewListenerCodec)1