Search in sources :

Example 1 with MigrationProgressNotification

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);
}
Also used : ListenerConfig(com.hazelcast.config.ListenerConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ListenerConfig(com.hazelcast.config.ListenerConfig) Config(com.hazelcast.config.Config) MigrationProgressNotification(com.hazelcast.internal.partition.impl.InternalMigrationListenerTest.MigrationProgressNotification) InternalPartition(com.hazelcast.internal.partition.InternalPartition) CountDownLatch(java.util.concurrent.CountDownLatch) InternalMigrationListenerImpl(com.hazelcast.internal.partition.impl.InternalMigrationListenerTest.InternalMigrationListenerImpl) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

Config (com.hazelcast.config.Config)1 ListenerConfig (com.hazelcast.config.ListenerConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 InternalPartition (com.hazelcast.internal.partition.InternalPartition)1 InternalMigrationListenerImpl (com.hazelcast.internal.partition.impl.InternalMigrationListenerTest.InternalMigrationListenerImpl)1 MigrationProgressNotification (com.hazelcast.internal.partition.impl.InternalMigrationListenerTest.MigrationProgressNotification)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Test (org.junit.Test)1