use of com.hazelcast.internal.partition.InternalPartition in project hazelcast by hazelcast.
the class MigrationCommitTest method shouldRollbackMigrationWhenDestinationCrashesBeforeCommit.
@Test
public void shouldRollbackMigrationWhenDestinationCrashesBeforeCommit() {
CountDownLatch migrationStartLatch = new CountDownLatch(1);
Config config1 = createConfig();
config1.setLiteMember(true);
TerminateOtherMemberOnMigrationComplete masterListener = new TerminateOtherMemberOnMigrationComplete(migrationStartLatch);
config1.addListenerConfig(new ListenerConfig(masterListener));
HazelcastInstance hz1 = factory.newHazelcastInstance(config1);
HazelcastInstance hz2 = factory.newHazelcastInstance(createConfig());
warmUpPartitions(hz1, hz2);
waitAllForSafeState(hz1, hz2);
masterListener.other = factory.newHazelcastInstance(createConfig());
migrationStartLatch.countDown();
sleepAtLeastSeconds(10);
waitAllForSafeState(hz1, hz2);
InternalPartition partition0 = getPartitionService(hz2).getPartition(0);
InternalPartition partition1 = getPartitionService(hz2).getPartition(1);
assertEquals(getAddress(hz2), partition0.getOwnerOrNull());
assertEquals(getAddress(hz2), partition1.getOwnerOrNull());
assertFalse(partition0.isMigrating());
assertFalse(partition1.isMigrating());
assertTrue(masterListener.rollback);
}
use of com.hazelcast.internal.partition.InternalPartition in project hazelcast by hazelcast.
the class MigrationCommitServiceTest method setup.
@Before
public void setup() throws Exception {
blockMigrationStartLatch = new CountDownLatch(1);
factory = createHazelcastInstanceFactory(NODE_COUNT);
instances = factory.newInstances(createConfig(), NODE_COUNT);
warmUpPartitions(instances);
waitAllForSafeState(instances);
InternalOperationService operationService = getOperationService(instances[0]);
for (int partitionId = 0; partitionId < PARTITION_COUNT; partitionId++) {
operationService.invokeOnPartition(null, new TestIncrementOperation(), partitionId).get();
}
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
for (int partitionId = 0; partitionId < PARTITION_COUNT; partitionId++) {
InternalPartitionService partitionService = getPartitionService(instances[0]);
InternalPartition partition = partitionService.getPartition(partitionId);
for (int i = 0; i <= BACKUP_COUNT; i++) {
Address replicaAddress = partition.getReplicaAddress(i);
if (replicaAddress != null) {
TestMigrationAwareService service = getService(replicaAddress);
assertNotNull(service.get(partitionId));
}
}
}
}
});
for (HazelcastInstance instance : instances) {
TestMigrationAwareService service = getNodeEngineImpl(instance).getService(TestMigrationAwareService.SERVICE_NAME);
service.clearEvents();
}
}
use of com.hazelcast.internal.partition.InternalPartition in project hazelcast by hazelcast.
the class PartitionReplicaStateChecker_triggerAndWaitForReplicaSyncTest method whenHasMissingReplicaOwners_withAddress_thenWaitForMissingReplicaOwners.
@Test
public void whenHasMissingReplicaOwners_withAddress_thenWaitForMissingReplicaOwners() throws Exception {
configureNeedsReplicaStateCheckResponse();
Address address = new Address("127.0.0.1", 5701);
InternalPartition partition = new DummyInternalPartition(new Address[] { address }, 1);
partitions.add(partition);
assertEquals(REPLICA_NOT_OWNED, replicaStateChecker.getPartitionServiceState());
assertFalse(replicaStateChecker.triggerAndWaitForReplicaSync(10, TimeUnit.MILLISECONDS, 5));
}
use of com.hazelcast.internal.partition.InternalPartition in project hazelcast by hazelcast.
the class PartitionReplicaStateChecker_triggerAndWaitForReplicaSyncTest method whenCheckAndTriggerReplicaSync.
@Test
public void whenCheckAndTriggerReplicaSync() throws Exception {
configureNeedsReplicaStateCheckResponseOnEachSecondCall();
InternalPartition partition = new DummyInternalPartition(new Address[] { null }, 1);
partitions.add(partition);
assertEquals(REPLICA_NOT_SYNC, replicaStateChecker.getPartitionServiceState());
assertFalse(replicaStateChecker.triggerAndWaitForReplicaSync(10, TimeUnit.MILLISECONDS, 5));
}
use of com.hazelcast.internal.partition.InternalPartition in project hazelcast by hazelcast.
the class PartitionReplicaStateChecker_triggerAndWaitForReplicaSyncTest method whenHasMissingReplicaOwners_withoutAddress_thenWaitForMissingReplicaOwners.
@Test
public void whenHasMissingReplicaOwners_withoutAddress_thenWaitForMissingReplicaOwners() {
configureNeedsReplicaStateCheckResponse();
InternalPartition partition = new DummyInternalPartition(new Address[0], 1);
partitions.add(partition);
assertEquals(REPLICA_NOT_OWNED, replicaStateChecker.getPartitionServiceState());
assertFalse(replicaStateChecker.triggerAndWaitForReplicaSync(10, TimeUnit.MILLISECONDS, 5));
}
Aggregations