Search in sources :

Example 1 with InternalMigrationListenerImpl

use of com.hazelcast.internal.partition.impl.InternalMigrationListenerTest.InternalMigrationListenerImpl 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)

Example 2 with InternalMigrationListenerImpl

use of com.hazelcast.internal.partition.impl.InternalMigrationListenerTest.InternalMigrationListenerImpl in project hazelcast by hazelcast.

the class MigrationCommitTest method shouldRetryMigrationIfParticipantPartitionTableVersionFallsBehind.

@Test
public void shouldRetryMigrationIfParticipantPartitionTableVersionFallsBehind() {
    CountDownLatch migrationStartLatch = new CountDownLatch(1);
    Config config1 = createConfig();
    config1.setLiteMember(true);
    final IncrementPartitionTableOnMigrationStart masterListener = new IncrementPartitionTableOnMigrationStart(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);
    migrationStartLatch.countDown();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertTrue(masterListener.failed);
        }
    });
    waitAllForSafeState(hz1, hz2, hz3);
}
Also used : ListenerConfig(com.hazelcast.config.ListenerConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ListenerConfig(com.hazelcast.config.ListenerConfig) Config(com.hazelcast.config.Config) AssertTask(com.hazelcast.test.AssertTask) 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)2 ListenerConfig (com.hazelcast.config.ListenerConfig)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 InternalMigrationListenerImpl (com.hazelcast.internal.partition.impl.InternalMigrationListenerTest.InternalMigrationListenerImpl)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Test (org.junit.Test)2 InternalPartition (com.hazelcast.internal.partition.InternalPartition)1 MigrationProgressNotification (com.hazelcast.internal.partition.impl.InternalMigrationListenerTest.MigrationProgressNotification)1 AssertTask (com.hazelcast.test.AssertTask)1