use of com.hazelcast.internal.partition.InternalPartition in project hazelcast by hazelcast.
the class TestPartitionUtils method getReplicaAddresses.
public static List<Address> getReplicaAddresses(Node node, int partitionId) {
List<Address> replicaAddresses = new ArrayList<Address>();
InternalPartitionService partitionService = node.getPartitionService();
InternalPartition partition = partitionService.getPartition(partitionId);
for (int i = 0; i < MAX_REPLICA_COUNT; i++) {
replicaAddresses.add(partition.getReplicaAddress(i));
}
return replicaAddresses;
}
use of com.hazelcast.internal.partition.InternalPartition in project hazelcast by hazelcast.
the class PartitionLostListenerTest method test_partitionLostListenerInvoked_whenNodeCrashed.
@Test
public void test_partitionLostListenerInvoked_whenNodeCrashed() {
HazelcastInstance survivingInstance = instances[0];
HazelcastInstance terminatingInstance = instances[1];
warmUpPartitions(instances);
waitAllForSafeState(instances);
final EventCollectingPartitionLostListener listener = new EventCollectingPartitionLostListener();
survivingInstance.getPartitionService().addPartitionLostListener(listener);
Node survivingNode = getNode(survivingInstance);
final Address survivingAddress = survivingNode.getThisAddress();
final Set<Integer> survivingPartitionIds = new HashSet<Integer>();
for (InternalPartition partition : survivingNode.getPartitionService().getInternalPartitions()) {
if (survivingAddress.equals(partition.getReplicaAddress(0))) {
survivingPartitionIds.add(partition.getPartitionId());
}
}
terminatingInstance.getLifecycleService().terminate();
waitAllForSafeState(survivingInstance);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
List<PartitionLostEvent> events = listener.getEvents();
assertFalse(events.isEmpty());
for (PartitionLostEvent event : events) {
assertEquals(survivingAddress, event.getEventSource());
assertFalse(survivingPartitionIds.contains(event.getPartitionId()));
assertEquals(0, event.getLostBackupCount());
}
}
});
}
use of com.hazelcast.internal.partition.InternalPartition in project hazelcast by hazelcast.
the class MigrationCommitServiceTest method createMoveMigration.
private MigrationInfo createMoveMigration(int partitionId, int replicaIndex, Address destination) {
InternalPartition partition = getPartition(instances[0], partitionId);
Address source = partition.getReplicaAddress(replicaIndex);
String sourceUuid = getMemberUuid(source);
String destinationUuid = getMemberUuid(destination);
return new MigrationInfo(partitionId, source, sourceUuid, destination, destinationUuid, replicaIndex, -1, -1, replicaIndex);
}
use of com.hazelcast.internal.partition.InternalPartition in project hazelcast by hazelcast.
the class MigrationCommitTest method shouldCommitMigrationWhenMasterIsDestination.
@Test
public void shouldCommitMigrationWhenMasterIsDestination() {
HazelcastInstance hz1 = factory.newHazelcastInstance(createConfig());
warmUpPartitions(hz1);
HazelcastInstance hz2 = factory.newHazelcastInstance(createConfig());
warmUpPartitions(hz1, hz2);
waitAllForSafeState(hz1, hz2);
hz2.getLifecycleService().terminate();
assertClusterSizeEventually(1, hz1);
waitAllForSafeState(hz1);
InternalPartition partition0 = getPartitionService(hz1).getPartition(0);
InternalPartition partition1 = getPartitionService(hz1).getPartition(1);
assertEquals(getAddress(hz1), partition0.getOwnerOrNull());
assertEquals(getAddress(hz1), partition1.getOwnerOrNull());
assertFalse(partition0.isMigrating());
assertFalse(partition1.isMigrating());
}
use of com.hazelcast.internal.partition.InternalPartition in project hazelcast by hazelcast.
the class MigrationCommitTest method shouldCommitMigrationWhenMasterIsNotMigrationEndpoint.
@Test
public void shouldCommitMigrationWhenMasterIsNotMigrationEndpoint() {
Config config1 = createConfig();
config1.setLiteMember(true);
HazelcastInstance hz1 = factory.newHazelcastInstance(config1);
HazelcastInstance hz2 = factory.newHazelcastInstance(createConfig());
warmUpPartitions(hz1, hz2);
waitAllForSafeState(hz1, hz2);
HazelcastInstance hz3 = factory.newHazelcastInstance(createConfig());
warmUpPartitions(hz3);
waitAllForSafeState(hz1, hz2, hz3);
InternalPartition hz2Partition = getOwnedPartition(hz2);
InternalPartition hz3Partition = getOwnedPartition(hz3);
assertNotNull(hz2Partition);
assertNotNull(hz3Partition);
assertNotEquals(hz2Partition, hz3Partition);
assertFalse(hz2Partition.isMigrating());
assertFalse(hz3Partition.isMigrating());
}
Aggregations