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));
}
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));
}
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());
}
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);
}
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);
}
Aggregations