Search in sources :

Example 6 with ReliableTopicConfig

use of com.hazelcast.config.ReliableTopicConfig in project hazelcast by hazelcast.

the class TopicOverloadTest method setupCluster.

@Before
public void setupCluster() {
    Config config = new Config();
    config.addRingBufferConfig(new RingbufferConfig("when*").setCapacity(100).setTimeToLiveSeconds(30));
    config.addReliableTopicConfig(new ReliableTopicConfig("whenError_*").setTopicOverloadPolicy(TopicOverloadPolicy.ERROR));
    config.addReliableTopicConfig(new ReliableTopicConfig("whenDiscardOldest_*").setTopicOverloadPolicy(TopicOverloadPolicy.DISCARD_OLDEST));
    config.addReliableTopicConfig(new ReliableTopicConfig("whenDiscardNewest_*").setTopicOverloadPolicy(TopicOverloadPolicy.DISCARD_NEWEST));
    config.addReliableTopicConfig(new ReliableTopicConfig("whenBlock_*").setTopicOverloadPolicy(TopicOverloadPolicy.BLOCK));
    HazelcastInstance hz = createHazelcastInstance(config);
    serializationService = getSerializationService(hz);
    String topicName = getTestMethodName();
    topic = hz.<String>getReliableTopic(topicName);
    ringbuffer = ((ReliableTopicProxy<String>) topic).ringbuffer;
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) Config(com.hazelcast.config.Config) RingbufferConfig(com.hazelcast.config.RingbufferConfig) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) Before(org.junit.Before)

Example 7 with ReliableTopicConfig

use of com.hazelcast.config.ReliableTopicConfig in project hazelcast by hazelcast.

the class ReliableTopicCreateTest method testConfiguredListenerClassAndHazelcastInstanceAware.

@Test
public void testConfiguredListenerClassAndHazelcastInstanceAware() {
    Config config = new Config();
    config.addReliableTopicConfig(new ReliableTopicConfig("foo*").addMessageListenerConfig(new ListenerConfig(InstanceAwareReliableMessageListenerMock.class.getName())));
    HazelcastInstance hz = createHazelcastInstance(config);
    ITopic topic = hz.getReliableTopic("foo");
    ReliableTopicProxy proxy = assertInstanceOf(ReliableTopicProxy.class, topic);
    // check there is one listener.
    assertEquals(1, proxy.runnersMap.size());
    // check that the listener is of the right class.
    ReliableMessageListenerRunner runner = (ReliableMessageListenerRunner) proxy.runnersMap.values().iterator().next();
    InstanceAwareReliableMessageListenerMock mock = assertInstanceOf(InstanceAwareReliableMessageListenerMock.class, runner.listener);
    assertNotNull(mock.hz);
}
Also used : ListenerConfig(com.hazelcast.config.ListenerConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ITopic(com.hazelcast.core.ITopic) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) ListenerConfig(com.hazelcast.config.ListenerConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) Config(com.hazelcast.config.Config) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 8 with ReliableTopicConfig

use of com.hazelcast.config.ReliableTopicConfig 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();
}
Also used : ListenerConfig(com.hazelcast.config.ListenerConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) ListenerConfig(com.hazelcast.config.ListenerConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) Config(com.hazelcast.config.Config) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 9 with ReliableTopicConfig

use of com.hazelcast.config.ReliableTopicConfig 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");
        }
    });
}
Also used : ListenerConfig(com.hazelcast.config.ListenerConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) ListenerConfig(com.hazelcast.config.ListenerConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) Config(com.hazelcast.config.Config) AssertTask(com.hazelcast.test.AssertTask) HazelcastException(com.hazelcast.core.HazelcastException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 10 with ReliableTopicConfig

use of com.hazelcast.config.ReliableTopicConfig in project hazelcast by hazelcast.

the class ReliableTopicAbstractTest method setup.

@Before
public void setup() {
    ReliableTopicConfig topicConfig = new ReliableTopicConfig("reliableTopic*");
    RingbufferConfig ringbufferConfig = new RingbufferConfig(topicConfig.getName());
    ringbufferConfig.setCapacity(CAPACITY);
    Config config = new Config();
    config.addReliableTopicConfig(topicConfig);
    config.addRingBufferConfig(ringbufferConfig);
    HazelcastInstance[] instances = newInstances(config);
    local = instances[0];
    HazelcastInstance target = instances[instances.length - 1];
    String name = randomNameOwnedBy(target, "reliableTopic");
    topic = (ReliableTopicProxy<String>) local.<String>getReliableTopic(name);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) Config(com.hazelcast.config.Config) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) Before(org.junit.Before)

Aggregations

ReliableTopicConfig (com.hazelcast.config.ReliableTopicConfig)11 Config (com.hazelcast.config.Config)10 RingbufferConfig (com.hazelcast.config.RingbufferConfig)10 HazelcastInstance (com.hazelcast.core.HazelcastInstance)10 ListenerConfig (com.hazelcast.config.ListenerConfig)8 QuickTest (com.hazelcast.test.annotation.QuickTest)8 Test (org.junit.Test)8 ParallelTest (com.hazelcast.test.annotation.ParallelTest)7 Before (org.junit.Before)3 HazelcastException (com.hazelcast.core.HazelcastException)2 ITopic (com.hazelcast.core.ITopic)2 AssertTask (com.hazelcast.test.AssertTask)2 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)1 ItemListenerConfig (com.hazelcast.config.ItemListenerConfig)1 MapPartitionLostListenerConfig (com.hazelcast.config.MapPartitionLostListenerConfig)1 Ringbuffer (com.hazelcast.ringbuffer.Ringbuffer)1 RingbufferService (com.hazelcast.ringbuffer.impl.RingbufferService)1