Search in sources :

Example 91 with PartitionReplica

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

the class MigrationPlannerCycleTest method testCycle1.

@Test
public void testCycle1() throws UnknownHostException {
    final PartitionReplica[] oldReplicas = { new PartitionReplica(new Address("localhost", 5701), uuids[0]), new PartitionReplica(new Address("localhost", 5702), uuids[1]), null, null, null, null, null };
    final PartitionReplica[] newReplicas = { new PartitionReplica(new Address("localhost", 5702), uuids[1]), new PartitionReplica(new Address("localhost", 5701), uuids[0]), null, null, null, null, null };
    assertTrue(migrationPlanner.isCyclic(oldReplicas, newReplicas));
}
Also used : Address(com.hazelcast.cluster.Address) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 92 with PartitionReplica

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

the class MigrationPlannerCycleTest method testNoCycle.

@Test
public void testNoCycle() throws UnknownHostException {
    final PartitionReplica[] oldReplicas = { new PartitionReplica(new Address("localhost", 5701), uuids[0]), new PartitionReplica(new Address("localhost", 5702), uuids[1]), null, null, null, null, null };
    final PartitionReplica[] newReplicas = { new PartitionReplica(new Address("localhost", 5702), uuids[1]), new PartitionReplica(new Address("localhost", 5703), uuids[2]), null, null, null, null, null };
    assertFalse(migrationPlanner.isCyclic(oldReplicas, newReplicas));
}
Also used : Address(com.hazelcast.cluster.Address) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 93 with PartitionReplica

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

the class PartitionReplicaStateCheckerTest method shouldNotBeSafe_whenUnknownReplicaOwnerPresent_whileNotActive.

@Test
public void shouldNotBeSafe_whenUnknownReplicaOwnerPresent_whileNotActive() throws UnknownHostException {
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
    HazelcastInstance hz = factory.newHazelcastInstance();
    HazelcastInstance hz2 = factory.newHazelcastInstance();
    InternalPartitionServiceImpl partitionService = getNode(hz).partitionService;
    partitionService.firstArrangement();
    changeClusterStateEventually(hz2, ClusterState.FROZEN);
    hz2.shutdown();
    assertClusterSizeEventually(1, hz);
    PartitionStateManager partitionStateManager = partitionService.getPartitionStateManager();
    InternalPartitionImpl partition = partitionStateManager.getPartitionImpl(0);
    PartitionReplica[] members = partition.replicas();
    PartitionReplica[] illegalMembers = Arrays.copyOf(members, members.length);
    Address address = members[0].address();
    illegalMembers[0] = new PartitionReplica(new Address(address.getInetAddress(), address.getPort() + 1000), members[0].uuid());
    partition.setReplicas(illegalMembers);
    PartitionReplicaStateChecker replicaStateChecker = partitionService.getPartitionReplicaStateChecker();
    assertEquals(PartitionServiceState.REPLICA_NOT_OWNED, replicaStateChecker.getPartitionServiceState());
    partition.setReplicas(members);
    assertEquals(PartitionServiceState.SAFE, replicaStateChecker.getPartitionServiceState());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.cluster.Address) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 94 with PartitionReplica

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

the class MigrationPlannerTest method test_SHIFT_DOWN_performedBeforeNonConflicting_SHIFT_UP.

@Test
public void test_SHIFT_DOWN_performedBeforeNonConflicting_SHIFT_UP() throws UnknownHostException {
    final PartitionReplica[] oldReplicas = { new PartitionReplica(new Address("localhost", 5701), uuids[0]), new PartitionReplica(new Address("localhost", 5702), uuids[1]), new PartitionReplica(new Address("localhost", 5703), uuids[2]), new PartitionReplica(new Address("localhost", 5705), uuids[4]), null, null, null };
    final PartitionReplica[] newReplicas = { new PartitionReplica(new Address("localhost", 5704), uuids[3]), new PartitionReplica(new Address("localhost", 5703), uuids[2]), new PartitionReplica(new Address("localhost", 5705), uuids[4]), new PartitionReplica(new Address("localhost", 5706), uuids[5]), new PartitionReplica(new Address("localhost", 5701), uuids[0]), null, null };
    migrationPlanner.planMigrations(0, oldReplicas, newReplicas, callback);
    verify(callback).migrate(new PartitionReplica(new Address("localhost", 5701), uuids[0]), 0, 4, new PartitionReplica(new Address("localhost", 5704), uuids[3]), -1, 0);
    verify(callback).migrate(new PartitionReplica(new Address("localhost", 5705), uuids[4]), 3, -1, new PartitionReplica(new Address("localhost", 5706), uuids[5]), -1, 3);
    verify(callback).migrate(new PartitionReplica(new Address("localhost", 5703), uuids[2]), 2, -1, new PartitionReplica(new Address("localhost", 5705), uuids[4]), -1, 2);
}
Also used : Address(com.hazelcast.cluster.Address) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 95 with PartitionReplica

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

the class ReplicaSyncInfoTest method setUp.

@Before
public void setUp() throws Exception {
    int partitionId = 23;
    int replicaIndex = 42;
    PartitionReplica target = new PartitionReplica(new Address("127.0.0.1", 5701), new UUID(57, 1));
    PartitionReplica otherTarget = new PartitionReplica(new Address("127.0.0.1", 5702), new UUID(57, 2));
    replicaSyncInfo = new ReplicaFragmentSyncInfo(partitionId, NonFragmentedServiceNamespace.INSTANCE, replicaIndex, target);
    replicaSyncInfoSameAttributes = new ReplicaFragmentSyncInfo(partitionId, NonFragmentedServiceNamespace.INSTANCE, replicaIndex, target);
    replicaSyncInfoOtherTarget = new ReplicaFragmentSyncInfo(partitionId, NonFragmentedServiceNamespace.INSTANCE, replicaIndex, otherTarget);
    replicaSyncInfoOtherPartitionId = new ReplicaFragmentSyncInfo(24, NonFragmentedServiceNamespace.INSTANCE, replicaIndex, target);
    replicaSyncInfoOtherReplicaIndex = new ReplicaFragmentSyncInfo(partitionId, NonFragmentedServiceNamespace.INSTANCE, 43, target);
}
Also used : Address(com.hazelcast.cluster.Address) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) UUID(java.util.UUID) Before(org.junit.Before)

Aggregations

PartitionReplica (com.hazelcast.internal.partition.PartitionReplica)103 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)51 QuickTest (com.hazelcast.test.annotation.QuickTest)51 Test (org.junit.Test)51 Address (com.hazelcast.cluster.Address)44 InternalPartition (com.hazelcast.internal.partition.InternalPartition)17 MigrationInfo (com.hazelcast.internal.partition.MigrationInfo)17 ArrayList (java.util.ArrayList)10 Member (com.hazelcast.cluster.Member)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)7 PartitionTableView (com.hazelcast.internal.partition.PartitionTableView)6 ReadonlyInternalPartition (com.hazelcast.internal.partition.ReadonlyInternalPartition)6 ClusterState (com.hazelcast.cluster.ClusterState)5 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)5 NodeEngine (com.hazelcast.spi.impl.NodeEngine)4 Operation (com.hazelcast.spi.impl.operationservice.Operation)4 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)3 MemberLeftException (com.hazelcast.core.MemberLeftException)3 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)3