Search in sources :

Example 26 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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 27 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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 28 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);
    final ConcurrentMap<Integer, Map<ObjectNamespace, RingbufferContainer>> containers = ringbufferService.getContainers();
    assertEquals(1, containers.size());
    final Map<ObjectNamespace, RingbufferContainer> partitionContainers = containers.get(ringbufferService.getRingbufferPartitionId(ringbuffer.getName()));
    final ObjectNamespace ns = RingbufferService.getRingbufferNamespace(ringbuffer.getName());
    assertTrue(partitionContainers.containsKey(ns));
    assertEquals(0, ringbuffer.headSequence());
    assertEquals(0, ringbuffer.tailSequence());
    assertEquals(10, ringbuffer.capacity());
}
Also used : RingbufferContainer(com.hazelcast.ringbuffer.impl.RingbufferContainer) 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) HazelcastInstance(com.hazelcast.core.HazelcastInstance) RingbufferConfig(com.hazelcast.config.RingbufferConfig) RingbufferService(com.hazelcast.ringbuffer.impl.RingbufferService) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 29 with ReliableTopicConfig

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

the class ReliableTopicBlockTest method setup.

@Before
public void setup() {
    Config config = smallInstanceConfig();
    config.addRingBufferConfig(new RingbufferConfig("blockingReliableTopic*").setCapacity(10).setTimeToLiveSeconds(60));
    config.addReliableTopicConfig(new ReliableTopicConfig("blockingReliableTopic*").setReadBatchSize(10).setTopicOverloadPolicy(TopicOverloadPolicy.BLOCK));
    HazelcastInstance[] instances = createHazelcastInstanceFactory(1).newInstances(config);
    local = instances[0];
    HazelcastInstance target = instances[instances.length - 1];
    String name = randomNameOwnedBy(target, "reliableTopic");
    topic = local.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)

Example 30 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);
    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) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) Config(com.hazelcast.config.Config) RingbufferConfig(com.hazelcast.config.RingbufferConfig) Before(org.junit.Before)

Aggregations

ReliableTopicConfig (com.hazelcast.config.ReliableTopicConfig)30 RingbufferConfig (com.hazelcast.config.RingbufferConfig)17 Config (com.hazelcast.config.Config)16 Test (org.junit.Test)15 HazelcastInstance (com.hazelcast.core.HazelcastInstance)14 QuickTest (com.hazelcast.test.annotation.QuickTest)14 ListenerConfig (com.hazelcast.config.ListenerConfig)13 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)13 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)6 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)6 DurableExecutorConfig (com.hazelcast.config.DurableExecutorConfig)6 ExecutorConfig (com.hazelcast.config.ExecutorConfig)6 FlakeIdGeneratorConfig (com.hazelcast.config.FlakeIdGeneratorConfig)6 ListConfig (com.hazelcast.config.ListConfig)6 MapConfig (com.hazelcast.config.MapConfig)6 MultiMapConfig (com.hazelcast.config.MultiMapConfig)6 PNCounterConfig (com.hazelcast.config.PNCounterConfig)6 QueueConfig (com.hazelcast.config.QueueConfig)6 ReplicatedMapConfig (com.hazelcast.config.ReplicatedMapConfig)6 ScheduledExecutorConfig (com.hazelcast.config.ScheduledExecutorConfig)6