Search in sources :

Example 6 with Ringbuffer

use of com.hazelcast.ringbuffer.Ringbuffer 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

Ringbuffer (com.hazelcast.ringbuffer.Ringbuffer)6 ParallelTest (com.hazelcast.test.annotation.ParallelTest)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Test (org.junit.Test)6 HazelcastInstance (com.hazelcast.core.HazelcastInstance)5 RingbufferService (com.hazelcast.ringbuffer.impl.RingbufferService)4 Config (com.hazelcast.config.Config)2 ListenerConfig (com.hazelcast.config.ListenerConfig)2 ReliableTopicConfig (com.hazelcast.config.ReliableTopicConfig)2 RingbufferConfig (com.hazelcast.config.RingbufferConfig)2 RingbufferContainer (com.hazelcast.ringbuffer.impl.RingbufferContainer)2 PartitionMigrationEvent (com.hazelcast.spi.PartitionMigrationEvent)1