Search in sources :

Example 36 with PartitionReplica

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

the class MigrationPlannerTest method test_SHIFT_UP_nonNullSource_willGetAnotherMOVE.

@Test
public void test_SHIFT_UP_nonNullSource_willGetAnotherMOVE() 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]), null, null, null, null };
    final PartitionReplica[] newReplicas = { new PartitionReplica(new Address("localhost", 5703), uuids[2]), new PartitionReplica(new Address("localhost", 5701), uuids[0]), null, null, null, null, null };
    migrationPlanner.planMigrations(0, oldReplicas, newReplicas, callback);
    verify(callback).migrate(new PartitionReplica(new Address("localhost", 5701), uuids[0]), 0, -1, new PartitionReplica(new Address("localhost", 5703), uuids[2]), 2, 0);
    verify(callback).migrate(new PartitionReplica(new Address("localhost", 5702), uuids[1]), 1, -1, new PartitionReplica(new Address("localhost", 5701), uuids[0]), -1, 1);
}
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 37 with PartitionReplica

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

the class MigrationPlannerTest method test_SHIFT_UP_SHIFT_DOWN_atomicTogether.

@Test
public void test_SHIFT_UP_SHIFT_DOWN_atomicTogether() throws UnknownHostException {
    final PartitionReplica[] oldReplicas = { new PartitionReplica(new Address("localhost", 5701), uuids[0]), null, new PartitionReplica(new Address("localhost", 5703), uuids[2]), null, null, null, null };
    final PartitionReplica[] newReplicas = { new PartitionReplica(new Address("localhost", 5703), uuids[2]), new PartitionReplica(new Address("localhost", 5701), uuids[0]), null, null, null, null, null };
    migrationPlanner.planMigrations(0, oldReplicas, newReplicas, callback);
    verify(callback).migrate(new PartitionReplica(new Address("localhost", 5701), uuids[0]), 0, 1, new PartitionReplica(new Address("localhost", 5703), uuids[2]), 2, 0);
}
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 38 with PartitionReplica

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

the class MigrationPlannerTest method testCopyPrioritizationAgainstMove.

@Test
public void testCopyPrioritizationAgainstMove() throws UnknownHostException {
    List<MigrationInfo> migrations = new ArrayList<MigrationInfo>();
    final MigrationInfo migration1 = new MigrationInfo(0, null, new PartitionReplica(new Address("localhost", 5701), uuids[0]), -1, -1, -1, 0);
    final MigrationInfo migration2 = new MigrationInfo(0, null, new PartitionReplica(new Address("localhost", 5702), uuids[1]), -1, -1, -1, 1);
    final MigrationInfo migration3 = new MigrationInfo(0, new PartitionReplica(new Address("localhost", 5703), uuids[2]), new PartitionReplica(new Address("localhost", 5704), uuids[3]), 2, -1, -1, 2);
    final MigrationInfo migration4 = new MigrationInfo(0, new PartitionReplica(new Address("localhost", 5705), uuids[4]), new PartitionReplica(new Address("localhost", 5706), uuids[5]), 2, -1, -1, 3);
    final MigrationInfo migration5 = new MigrationInfo(0, null, new PartitionReplica(new Address("localhost", 5707), uuids[6]), -1, -1, -1, 4);
    migrations.add(migration1);
    migrations.add(migration2);
    migrations.add(migration3);
    migrations.add(migration4);
    migrations.add(migration5);
    migrationPlanner.prioritizeCopiesAndShiftUps(migrations);
    assertEquals(asList(migration1, migration2, migration5, migration3, migration4), migrations);
}
Also used : MigrationInfo(com.hazelcast.internal.partition.MigrationInfo) Address(com.hazelcast.cluster.Address) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) ArrayList(java.util.ArrayList) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 39 with PartitionReplica

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

the class MigrationPlannerTest method testShiftUpPrioritizationAgainstMove.

@Test
public void testShiftUpPrioritizationAgainstMove() throws UnknownHostException {
    List<MigrationInfo> migrations = new ArrayList<MigrationInfo>();
    final MigrationInfo migration1 = new MigrationInfo(0, null, new PartitionReplica(new Address("localhost", 5701), uuids[0]), -1, -1, -1, 0);
    final MigrationInfo migration2 = new MigrationInfo(0, null, new PartitionReplica(new Address("localhost", 5702), uuids[1]), -1, -1, -1, 1);
    final MigrationInfo migration3 = new MigrationInfo(0, new PartitionReplica(new Address("localhost", 5705), uuids[4]), new PartitionReplica(new Address("localhost", 5706), uuids[5]), 2, -1, -1, 3);
    final MigrationInfo migration4 = new MigrationInfo(0, null, new PartitionReplica(new Address("localhost", 5707), uuids[6]), -1, -1, 4, 2);
    migrations.add(migration1);
    migrations.add(migration2);
    migrations.add(migration3);
    migrations.add(migration4);
    migrationPlanner.prioritizeCopiesAndShiftUps(migrations);
    assertEquals(asList(migration1, migration2, migration4, migration3), migrations);
}
Also used : MigrationInfo(com.hazelcast.internal.partition.MigrationInfo) Address(com.hazelcast.cluster.Address) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) ArrayList(java.util.ArrayList) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 40 with PartitionReplica

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

the class MigrationPlannerTest method testNoCopyPrioritizationAgainstCopy.

@Test
public void testNoCopyPrioritizationAgainstCopy() throws UnknownHostException {
    List<MigrationInfo> migrations = new ArrayList<MigrationInfo>();
    final MigrationInfo migration1 = new MigrationInfo(0, null, new PartitionReplica(new Address("localhost", 5701), uuids[0]), -1, -1, -1, 0);
    final MigrationInfo migration2 = new MigrationInfo(0, null, new PartitionReplica(new Address("localhost", 5702), uuids[1]), -1, -1, -1, 1);
    final MigrationInfo migration3 = new MigrationInfo(0, null, new PartitionReplica(new Address("localhost", 5703), uuids[2]), -1, -1, -1, 2);
    final MigrationInfo migration4 = new MigrationInfo(0, null, new PartitionReplica(new Address("localhost", 5704), uuids[3]), -1, -1, -1, 3);
    migrations.add(migration1);
    migrations.add(migration2);
    migrations.add(migration3);
    migrations.add(migration4);
    migrationPlanner.prioritizeCopiesAndShiftUps(migrations);
    assertEquals(asList(migration1, migration2, migration3, migration4), migrations);
}
Also used : MigrationInfo(com.hazelcast.internal.partition.MigrationInfo) Address(com.hazelcast.cluster.Address) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) ArrayList(java.util.ArrayList) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

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