Search in sources :

Example 66 with RingbufferConfig

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

the class RingbufferTTLTest method whenTTLEnabled_thenVisibilityIsGuaranteed.

// if ttl is set, we need to make sure that during that period all items are accessible.
// In this particular test we set the ttl period to 10 second. The minimumVisibilitySeconds to
// give us an error margin of 2 seconds (due to threading etc... we don't want to have another
// spurious failing test.
@Test
public void whenTTLEnabled_thenVisibilityIsGuaranteed() {
    int ttl = 10;
    int minimumVisibleTTL = ttl - 2;
    setup(new RingbufferConfig("foo").setTimeToLiveSeconds(ttl).setCapacity(100));
    for (int k = 0; k < ringbuffer.capacity(); k++) {
        ringbuffer.add("item" + k);
    }
    final long head = ringbuffer.headSequence();
    final long tail = ringbuffer.tailSequence();
    final long size = ringbuffer.size();
    assertTrueAllTheTime(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(head, ringbuffer.headSequence());
            assertEquals(tail, ringbuffer.tailSequence());
            assertEquals(size, ringbuffer.size());
            for (long seq = head; seq <= tail; seq++) {
                assertEquals("item" + seq, ringbuffer.readOne(seq));
            }
        }
    }, minimumVisibleTTL);
}
Also used : RingbufferConfig(com.hazelcast.config.RingbufferConfig) AssertTask(com.hazelcast.test.AssertTask) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 67 with RingbufferConfig

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

the class StoreLatencyPluginRingbufferIntegrationTest method setup.

@Before
public void setup() throws Exception {
    Config config = new Config().setProperty("hazelcast.diagnostics.enabled", "true").setProperty("hazelcast.diagnostics.storeLatency.period.seconds", "1");
    RingbufferConfig rbConfig = addRingbufferConfig(config);
    hz = createHazelcastInstance(config);
    rb = hz.getRingbuffer(rbConfig.getName());
}
Also used : RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig) Config(com.hazelcast.config.Config) RingbufferConfig(com.hazelcast.config.RingbufferConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) Before(org.junit.Before)

Example 68 with RingbufferConfig

use of com.hazelcast.config.RingbufferConfig 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 69 with RingbufferConfig

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

the class ReliableTopicStressTest method setup.

@Before
public void setup() {
    Config config = new Config();
    RingbufferConfig ringbufferConfig = new RingbufferConfig("foobar");
    ringbufferConfig.setCapacity(1000 * 1000);
    ringbufferConfig.setTimeToLiveSeconds(5);
    config.addRingBufferConfig(ringbufferConfig);
    TopicConfig topicConfig = new TopicConfig("foobar");
    config.addTopicConfig(topicConfig);
    HazelcastInstance hz = createHazelcastInstance(config);
    topic = hz.getReliableTopic(topicConfig.getName());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) RingbufferConfig(com.hazelcast.config.RingbufferConfig) TopicConfig(com.hazelcast.config.TopicConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) TopicConfig(com.hazelcast.config.TopicConfig) Before(org.junit.Before)

Example 70 with RingbufferConfig

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

the class LossToleranceTest method setup.

@Before
public void setup() {
    Config config = smallInstanceConfig().addRingBufferConfig(new RingbufferConfig(RELIABLE_TOPIC_NAME).setCapacity(100).setTimeToLiveSeconds(0).setBackupCount(0).setAsyncBackupCount(0));
    final HazelcastInstance[] instances = createHazelcastInstanceFactory(2).newInstances(config);
    warmUpPartitions(instances);
    for (HazelcastInstance instance : instances) {
        final Member owner = instance.getPartitionService().getPartition(TOPIC_RB_PREFIX + RELIABLE_TOPIC_NAME).getOwner();
        final Member localMember = instance.getCluster().getLocalMember();
        if (localMember.equals(owner)) {
            topicOwnerInstance = instance;
        } else {
            topicBackupInstance = instance;
        }
    }
    topic = (ReliableTopicProxy<String>) topicBackupInstance.<String>getReliableTopic(RELIABLE_TOPIC_NAME);
    ringbuffer = topic.ringbuffer;
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) RingbufferConfig(com.hazelcast.config.RingbufferConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) Member(com.hazelcast.cluster.Member) Before(org.junit.Before)

Aggregations

RingbufferConfig (com.hazelcast.config.RingbufferConfig)91 Test (org.junit.Test)43 Config (com.hazelcast.config.Config)35 QuickTest (com.hazelcast.test.annotation.QuickTest)26 HazelcastInstance (com.hazelcast.core.HazelcastInstance)22 Before (org.junit.Before)21 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)14 NightlyTest (com.hazelcast.test.annotation.NightlyTest)12 ReliableTopicConfig (com.hazelcast.config.ReliableTopicConfig)11 RingbufferStoreConfig (com.hazelcast.config.RingbufferStoreConfig)9 Data (com.hazelcast.internal.serialization.Data)7 TopicConfig (com.hazelcast.config.TopicConfig)6 ClientConfig (com.hazelcast.client.config.ClientConfig)5 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)5 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)5 DurableExecutorConfig (com.hazelcast.config.DurableExecutorConfig)5 ExecutorConfig (com.hazelcast.config.ExecutorConfig)5 FlakeIdGeneratorConfig (com.hazelcast.config.FlakeIdGeneratorConfig)5 ListConfig (com.hazelcast.config.ListConfig)5 MapConfig (com.hazelcast.config.MapConfig)5