Search in sources :

Example 31 with RingbufferConfig

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

the class RingbufferAsyncAddWithBackoffStressTest method whenTTLEnabled.

@Test
public void whenTTLEnabled() throws Exception {
    RingbufferConfig ringbufferConfig = new RingbufferConfig("foo").setCapacity(200 * 1000).setTimeToLiveSeconds(2);
    test(ringbufferConfig);
}
Also used : RingbufferConfig(com.hazelcast.config.RingbufferConfig) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 32 with RingbufferConfig

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

the class RingbufferContainerTest method constructionNoTTL.

// ======================= construction =======================
@Test
public void constructionNoTTL() {
    RingbufferConfig config = new RingbufferConfig("foo").setCapacity(100).setTimeToLiveSeconds(0);
    RingbufferContainer container = getRingbufferContainer(config);
    assertEquals(config.getCapacity(), container.getCapacity());
    assertNull(container.getExpirationPolicy());
    assertSame(config, container.getConfig());
    ArrayRingbuffer ringbuffer = (ArrayRingbuffer) container.getRingbuffer();
    assertNotNull(ringbuffer.getItems());
    assertEquals(config.getCapacity(), ringbuffer.getItems().length);
    assertEquals(-1, ringbuffer.tailSequence());
    assertEquals(0, ringbuffer.headSequence());
}
Also used : RingbufferConfig(com.hazelcast.config.RingbufferConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 33 with RingbufferConfig

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

the class RingbufferContainerTest method add.

// ======================= add =======================
@Test
public void add() {
    RingbufferConfig config = new RingbufferConfig("foo").setCapacity(10);
    RingbufferContainer<Data, Data> ringbuffer = getRingbufferContainer(config);
    ringbuffer.add(toData("foo"));
    ringbuffer.add(toData("bar"));
    assertEquals(1, ringbuffer.tailSequence());
    assertEquals(0, ringbuffer.headSequence());
}
Also used : RingbufferConfig(com.hazelcast.config.RingbufferConfig) Data(com.hazelcast.internal.serialization.Data) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 34 with RingbufferConfig

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

the class RingbufferContainerTest method constructionWithTTL.

@Test
public void constructionWithTTL() {
    RingbufferConfig config = new RingbufferConfig("foo").setCapacity(100).setTimeToLiveSeconds(30);
    RingbufferContainer ringbuffer = getRingbufferContainer(config);
    assertEquals(config.getCapacity(), ringbuffer.getCapacity());
    assertNotNull(ringbuffer.getExpirationPolicy());
    assertSame(config, ringbuffer.getConfig());
    assertEquals(config.getCapacity(), ringbuffer.getExpirationPolicy().ringExpirationMs.length);
    assertSame(config, ringbuffer.getConfig());
    assertEquals(-1, ringbuffer.tailSequence());
    assertEquals(0, ringbuffer.headSequence());
}
Also used : RingbufferConfig(com.hazelcast.config.RingbufferConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 35 with RingbufferConfig

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

the class RingbufferContainerTest method remainingCapacity_whenTTLEnabled.

@Test
public void remainingCapacity_whenTTLEnabled() {
    RingbufferConfig config = new RingbufferConfig("foo").setCapacity(100).setTimeToLiveSeconds(1);
    RingbufferContainer<Data, Data> ringbuffer = getRingbufferContainer(config);
    assertEquals(config.getCapacity(), ringbuffer.remainingCapacity());
    ringbuffer.add(toData("1"));
    assertEquals(config.getCapacity() - 1, ringbuffer.remainingCapacity());
    ringbuffer.add(toData("2"));
    assertEquals(config.getCapacity() - 2, ringbuffer.remainingCapacity());
}
Also used : RingbufferConfig(com.hazelcast.config.RingbufferConfig) Data(com.hazelcast.internal.serialization.Data) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

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