use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class MigrationPlannerTest method test_SHIFT_DOWN_performedAfterKnownNewReplicaOwnerKickedOutOfReplicas.
@Test
public void test_SHIFT_DOWN_performedAfterKnownNewReplicaOwnerKickedOutOfReplicas() 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", 5702), uuids[1]), new PartitionReplica(new Address("localhost", 5701), uuids[0]), null };
migrationPlanner.planMigrations(0, oldReplicas, newReplicas, callback);
verify(callback).migrate(new PartitionReplica(new Address("localhost", 5701), uuids[0]), 0, 5, 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);
verify(callback).migrate(new PartitionReplica(new Address("localhost", 5702), uuids[1]), 1, 4, new PartitionReplica(new Address("localhost", 5703), uuids[2]), -1, 1);
}
use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class MigrationPlannerTest method testSingleMigrationPrioritization.
@Test
public void testSingleMigrationPrioritization() 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);
migrations.add(migration1);
migrationPlanner.prioritizeCopiesAndShiftUps(migrations);
assertEquals(singletonList(migration1), migrations);
}
use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class MigrationPlannerTest method testCopyPrioritizationAgainstShiftDownToColderIndex.
@Test
public void testCopyPrioritizationAgainstShiftDownToColderIndex() throws UnknownHostException {
List<MigrationInfo> migrations = new ArrayList<MigrationInfo>();
final MigrationInfo migration1 = new MigrationInfo(0, new PartitionReplica(new Address("localhost", 5701), uuids[0]), new PartitionReplica(new Address("localhost", 5702), uuids[1]), 0, 2, -1, 0);
final MigrationInfo migration2 = new MigrationInfo(0, null, new PartitionReplica(new Address("localhost", 5703), uuids[2]), -1, -1, -1, 1);
migrations.add(migration1);
migrations.add(migration2);
migrationPlanner.prioritizeCopiesAndShiftUps(migrations);
assertEquals(asList(migration2, migration1), migrations);
}
use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class MigrationPlannerTest method test_SHIFT_UP.
@Test
public void test_SHIFT_UP() throws UnknownHostException {
final PartitionReplica[] oldReplicas = { new PartitionReplica(new Address("localhost", 5701), uuids[0]), null, new PartitionReplica(new Address("localhost", 5703), uuids[2]), new PartitionReplica(new Address("localhost", 5704), uuids[3]), null, null, null };
final PartitionReplica[] newReplicas = { new PartitionReplica(new Address("localhost", 5701), uuids[0]), new PartitionReplica(new Address("localhost", 5703), uuids[2]), new PartitionReplica(new Address("localhost", 5704), uuids[3]), null, null, null, null };
migrationPlanner.planMigrations(0, oldReplicas, newReplicas, callback);
verify(callback).migrate(null, -1, -1, new PartitionReplica(new Address("localhost", 5703), uuids[2]), 2, 1);
verify(callback).migrate(null, -1, -1, new PartitionReplica(new Address("localhost", 5704), uuids[3]), 3, 2);
}
use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class MigrationPlannerCycleTest method testCycle3.
@Test
public void testCycle3() 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", 5704), uuids[3]), new PartitionReplica(new Address("localhost", 5705), uuids[4]), null, null };
final PartitionReplica[] newReplicas = { new PartitionReplica(new Address("localhost", 5705), uuids[4]), new PartitionReplica(new Address("localhost", 5702), uuids[1]), new PartitionReplica(new Address("localhost", 5701), uuids[0]), new PartitionReplica(new Address("localhost", 5704), uuids[3]), new PartitionReplica(new Address("localhost", 5703), uuids[2]), null, null };
assertTrue(migrationPlanner.isCyclic(oldReplicas, newReplicas));
}
Aggregations