Search in sources :

Example 26 with RingbufferConfig

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

the class RingbufferContainerSerializationTest method test.

public void test(InMemoryFormat inMemoryFormat, int ttlSeconds) {
    final RingbufferConfig config = new RingbufferConfig("foobar").setCapacity(3).setAsyncBackupCount(2).setBackupCount(2).setInMemoryFormat(inMemoryFormat).setTimeToLiveSeconds(ttlSeconds);
    final RingbufferContainer rbContainer = getRingbufferContainer(config);
    testSerialization(rbContainer);
    for (int k = 0; k < config.getCapacity() * 2; k++) {
        rbContainer.add(toData("old"));
        testSerialization(rbContainer);
    }
    // now we are going to force the head to move
    final ArrayRingbuffer ringbuffer = (ArrayRingbuffer) rbContainer.getRingbuffer();
    for (int k = 0; k < config.getCapacity() / 2; k++) {
        ringbuffer.getItems()[k] = null;
        if (ttlSeconds != 0) {
            // we need to set the expiration slot to 0, because it won't be serialized (optimization)
            // serialization will only dump what is between head and tail
            rbContainer.getExpirationPolicy().ringExpirationMs[k] = 0;
        }
        ringbuffer.setHeadSequence(ringbuffer.headSequence() + 1);
        testSerialization(rbContainer);
    }
}
Also used : RingbufferConfig(com.hazelcast.config.RingbufferConfig)

Example 27 with RingbufferConfig

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

the class RingbufferAddAllReadManyStressTest method whenShortTTLAndBigBuffer.

@Test(timeout = MINUTE * 10)
public void whenShortTTLAndBigBuffer() {
    RingbufferConfig ringbufferConfig = new RingbufferConfig("rb").setInMemoryFormat(InMemoryFormat.OBJECT).setCapacity(20 * 1000 * 1000).setTimeToLiveSeconds(2);
    test(ringbufferConfig);
}
Also used : RingbufferConfig(com.hazelcast.config.RingbufferConfig) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 28 with RingbufferConfig

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

the class RingbufferAddAllReadManyStressTest method whenLongTTLAndSmallBuffer.

@Test(timeout = MINUTE * 10)
public void whenLongTTLAndSmallBuffer() {
    RingbufferConfig ringbufferConfig = new RingbufferConfig("rb").setCapacity(1000).setTimeToLiveSeconds(30);
    test(ringbufferConfig);
}
Also used : RingbufferConfig(com.hazelcast.config.RingbufferConfig) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 29 with RingbufferConfig

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

the class RingbufferAddAllReadManyStressTest method test.

public void test(RingbufferConfig ringbufferConfig) {
    Config config = smallInstanceConfig();
    config.addRingBufferConfig(ringbufferConfig);
    HazelcastInstance[] instances = createHazelcastInstanceFactory(2).newInstances(config);
    ringbuffer = instances[0].getRingbuffer(ringbufferConfig.getName());
    ConsumeThread consumer1 = new ConsumeThread(1);
    consumer1.start();
    ConsumeThread consumer2 = new ConsumeThread(2);
    consumer2.start();
    sleepSeconds(2);
    ProduceThread producer = new ProduceThread();
    producer.start();
    sleepAndStop(stop, 60);
    logger.info("Waiting for completion");
    producer.assertSucceedsEventually();
    consumer1.assertSucceedsEventually();
    consumer2.assertSucceedsEventually();
    logger.info(producer.getName() + " produced:" + producer.produced);
    assertEquals(producer.produced, consumer1.seq);
    assertEquals(producer.produced, consumer2.seq);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) RingbufferConfig(com.hazelcast.config.RingbufferConfig) Config(com.hazelcast.config.Config)

Example 30 with RingbufferConfig

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

the class RingbufferAsyncAddWithBackoffStressTest method whenLongTTLAndSmallBuffer.

@Test
public void whenLongTTLAndSmallBuffer() throws Exception {
    RingbufferConfig ringbufferConfig = new RingbufferConfig("foo").setCapacity(1000).setTimeToLiveSeconds(30);
    test(ringbufferConfig);
}
Also used : RingbufferConfig(com.hazelcast.config.RingbufferConfig) NightlyTest(com.hazelcast.test.annotation.NightlyTest) 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