use of com.hazelcast.internal.partition.impl.InternalMigrationListenerTest.MigrationProgressNotification in project hazelcast by hazelcast.
the class MigrationCommitTest method shouldCommitMigrationWhenSourceFailsDuringCommit.
@Test
public void shouldCommitMigrationWhenSourceFailsDuringCommit() {
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);
Config config3 = createConfig();
InternalMigrationListenerImpl targetListener = new InternalMigrationListenerImpl();
config3.addListenerConfig(new ListenerConfig(targetListener));
HazelcastInstance hz3 = factory.newHazelcastInstance(config3);
masterListener.other = hz2;
migrationStartLatch.countDown();
waitAllForSafeState(hz1, hz3);
InternalPartition partition0 = getPartitionService(hz3).getPartition(0);
InternalPartition partition1 = getPartitionService(hz3).getPartition(1);
assertEquals(getAddress(hz3), partition0.getOwnerOrNull());
assertEquals(getAddress(hz3), partition1.getOwnerOrNull());
assertFalse(partition0.isMigrating());
assertFalse(partition1.isMigrating());
assertFalse(masterListener.rollback);
List<MigrationProgressNotification> notifications = targetListener.getNotifications();
assertFalse(notifications.isEmpty());
assertEquals(COMMIT, notifications.get(notifications.size() - 1).event);
}
Aggregations