Search in sources :

Example 11 with ReliableTopicConfig

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

the class ReliableTopicCreateTest method testWildcardConfig.

@Test
public void testWildcardConfig() {
    Config config = new Config();
    config.addRingBufferConfig(new RingbufferConfig("foo*").setCapacity(10));
    config.addReliableTopicConfig(new ReliableTopicConfig("foo*").setTopicOverloadPolicy(DISCARD_NEWEST));
    HazelcastInstance hz = createHazelcastInstance(config);
    RingbufferService ringbufferService = getNodeEngineImpl(hz).getService(RingbufferService.SERVICE_NAME);
    ReliableTopicProxy<String> topic = (ReliableTopicProxy<String>) hz.<String>getReliableTopic("foo");
    Ringbuffer ringbuffer = topic.ringbuffer;
    topic.publish("foo");
    ReliableTopicProxy proxy = assertInstanceOf(ReliableTopicProxy.class, topic);
    assertEquals(proxy.overloadPolicy, TopicOverloadPolicy.DISCARD_NEWEST);
    assertEquals(1, ringbufferService.getContainers().size());
    assertTrue(ringbufferService.getContainers().containsKey(ringbuffer.getName()));
    assertEquals(0, ringbuffer.headSequence());
    assertEquals(0, ringbuffer.tailSequence());
    assertEquals(10, ringbuffer.capacity());
}
Also used : 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) Ringbuffer(com.hazelcast.ringbuffer.Ringbuffer) RingbufferConfig(com.hazelcast.config.RingbufferConfig) RingbufferService(com.hazelcast.ringbuffer.impl.RingbufferService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

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