use of com.hazelcast.config.ListenerConfig 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);
}
use of com.hazelcast.config.ListenerConfig in project hazelcast by hazelcast.
the class MigrationCommitTest method shouldEvictCompletedMigrationsWhenAllMembersAckPublishedPartitionTableAfterSuccessfulMigration.
@Test
public void shouldEvictCompletedMigrationsWhenAllMembersAckPublishedPartitionTableAfterSuccessfulMigration() {
CountDownLatch migrationStartLatch = new CountDownLatch(1);
Config config1 = createConfig();
config1.setLiteMember(true);
final CollectMigrationTaskOnCommit masterListener = new CollectMigrationTaskOnCommit();
config1.addListenerConfig(new ListenerConfig(masterListener));
HazelcastInstance hz1 = factory.newHazelcastInstance(config1);
InternalPartitionServiceImpl partitionService = (InternalPartitionServiceImpl) getPartitionService(hz1);
final MigrationManager migrationManager = partitionService.getMigrationManager();
HazelcastInstance hz2 = factory.newHazelcastInstance(createConfig());
warmUpPartitions(hz1, hz2);
waitAllForSafeState(hz1, hz2);
Config config3 = createConfig();
DelayMigrationStart destinationListener = new DelayMigrationStart(migrationStartLatch);
config3.addListenerConfig(new ListenerConfig(destinationListener));
HazelcastInstance hz3 = factory.newHazelcastInstance(config3);
migrationStartLatch.countDown();
waitAllForSafeState(hz1, hz2, hz3);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertTrue(masterListener.commit);
assertTrue(migrationManager.getCompletedMigrationsCopy().isEmpty());
}
});
}
use of com.hazelcast.config.ListenerConfig in project hazelcast by hazelcast.
the class ReliableTopicCreateTest method testConfiguredListenerClassNotExist.
@Test(expected = HazelcastException.class)
public void testConfiguredListenerClassNotExist() {
Config config = new Config();
config.addReliableTopicConfig(new ReliableTopicConfig("foo*").addMessageListenerConfig(new ListenerConfig("kfosajdajdksajdj")));
HazelcastInstance hz = createHazelcastInstance(config);
hz.getReliableTopic("foo");
fail();
}
use of com.hazelcast.config.ListenerConfig in project hazelcast by hazelcast.
the class ReliableTopicCreateTest method testConfiguredListenerInstance.
@Test
public void testConfiguredListenerInstance() {
final ReliableMessageListenerMock messageListener = new ReliableMessageListenerMock();
Config config = new Config();
config.addReliableTopicConfig(new ReliableTopicConfig("foo*").addMessageListenerConfig(new ListenerConfig(messageListener)));
HazelcastInstance hz = createHazelcastInstance(config);
ITopic<String> topic = hz.getReliableTopic("foo");
ReliableTopicProxy proxy = assertInstanceOf(ReliableTopicProxy.class, topic);
assertEquals(1, proxy.runnersMap.size());
topic.publish("item");
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertContains(messageListener.objects, "item");
}
});
}
use of com.hazelcast.config.ListenerConfig in project hazelcast by hazelcast.
the class TopicTest method testConfigListenerRegistration.
@Test
public void testConfigListenerRegistration() throws InterruptedException {
String topicName = "default";
Config config = new Config();
final CountDownLatch latch = new CountDownLatch(1);
config.getTopicConfig(topicName).addMessageListenerConfig(new ListenerConfig().setImplementation(new MessageListener() {
public void onMessage(Message message) {
latch.countDown();
}
}));
HazelcastInstance instance = createHazelcastInstance(config);
instance.getTopic(topicName).publish(1);
assertTrue(latch.await(10, TimeUnit.SECONDS));
}
Aggregations