Search in sources :

Example 41 with RingbufferConfig

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

the class RingbufferTTLTest method whenTTLEnabled_thenEventuallyRingbufferEmpties.

// when ttl is set, then eventually all the items needs to get expired.
// In this particular test we fill the ringbuffer and wait for it to expire.
// Expiration is given a 2 second martin of error. So we have a ttl of
// 10 seconds, then we expect that within 12 seconds the buffer is empty.
@Test
public void whenTTLEnabled_thenEventuallyRingbufferEmpties() throws Exception {
    int ttl = 10;
    int maximumVisibleTTL = ttl + 2;
    setup(new RingbufferConfig("foo").setTimeToLiveSeconds(ttl));
    for (int k = 0; k < ringbuffer.capacity(); k++) {
        ringbuffer.add("item" + k);
    }
    final long tail = ringbuffer.tailSequence();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(tail, ringbuffer.tailSequence());
            assertEquals(tail + 1, ringbuffer.headSequence());
            assertEquals(0, ringbuffer.size());
            assertEquals(ringbuffer.capacity(), ringbuffer.remainingCapacity());
        }
    }, maximumVisibleTTL);
    // and we verify that the slots are nulled so we don't have a memory leak on our hands.
    for (int k = 0; k < ringbuffer.capacity(); k++) {
        assertNull(arrayRingbuffer.getItems()[k]);
    }
}
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 42 with RingbufferConfig

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

the class RingbufferTTLTest method whenTTLEnabled_thenReadManyShouldSkipExpiredItems.

@Test
public void whenTTLEnabled_thenReadManyShouldSkipExpiredItems() throws Exception {
    setup(new RingbufferConfig("foo").setTimeToLiveSeconds(1).setCapacity(100));
    long head = ringbuffer.headSequence();
    ringbuffer.add("a");
    ReadResultSet<String> result = ringbuffer.readManyAsync(head, 0, 10, null).toCompletableFuture().get();
    assertThat(result).containsOnly("a");
    sleepMillis(1100);
    result = ringbuffer.readManyAsync(head, 0, 10, null).toCompletableFuture().get();
    assertThat(result).isEmpty();
}
Also used : RingbufferConfig(com.hazelcast.config.RingbufferConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 43 with RingbufferConfig

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

the class AddOperationsTest method setup.

@Before
public void setup() {
    RingbufferConfig rbConfig = new RingbufferConfig("foo").setCapacity(10).setTimeToLiveSeconds(10);
    Config config = new Config().addRingBufferConfig(rbConfig);
    HazelcastInstance hz = createHazelcastInstance(config);
    nodeEngine = getNodeEngineImpl(hz);
    ringbufferService = nodeEngine.getService(RingbufferService.SERVICE_NAME);
    serializationService = getSerializationService(hz);
    ringbuffer = hz.getRingbuffer(rbConfig.getName());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) RingbufferConfig(com.hazelcast.config.RingbufferConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) Before(org.junit.Before)

Example 44 with RingbufferConfig

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

the class MergePolicyValidatorRingbufferIntegrationTest method addConfig.

@Override
void addConfig(Config config, String name, MergePolicyConfig mergePolicyConfig) {
    RingbufferConfig ringbufferConfig = new RingbufferConfig(name).setMergePolicyConfig(mergePolicyConfig);
    config.addRingBufferConfig(ringbufferConfig);
}
Also used : RingbufferConfig(com.hazelcast.config.RingbufferConfig)

Example 45 with RingbufferConfig

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

the class AbstractDynamicConfigGeneratorTest method testRingbuffer.

private void testRingbuffer(RingbufferStoreConfig ringbufferStoreConfig) {
    MergePolicyConfig mergePolicyConfig = new MergePolicyConfig().setPolicy("PassThroughMergePolicy").setBatchSize(1234);
    RingbufferConfig expectedConfig = new RingbufferConfig("testRbConfig").setBackupCount(1).setAsyncBackupCount(2).setCapacity(3).setTimeToLiveSeconds(4).setInMemoryFormat(InMemoryFormat.BINARY).setRingbufferStoreConfig(ringbufferStoreConfig).setSplitBrainProtectionName("splitBrainProtection").setMergePolicyConfig(mergePolicyConfig);
    Config config = new Config().addRingBufferConfig(expectedConfig);
    Config decConfig = getNewConfigViaGenerator(config);
    RingbufferConfig actualConfig = decConfig.getRingbufferConfig(expectedConfig.getName());
    ConfigCompatibilityChecker.checkRingbufferConfig(expectedConfig, actualConfig);
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) ListConfig(com.hazelcast.config.ListConfig) EventJournalConfig(com.hazelcast.config.EventJournalConfig) AwsConfig(com.hazelcast.config.AwsConfig) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) MapConfig(com.hazelcast.config.MapConfig) PredicateConfig(com.hazelcast.config.PredicateConfig) MultiMapConfig(com.hazelcast.config.MultiMapConfig) PartitioningStrategyConfig(com.hazelcast.config.PartitioningStrategyConfig) ExecutorConfig(com.hazelcast.config.ExecutorConfig) DiscoveryStrategyConfig(com.hazelcast.config.DiscoveryStrategyConfig) DiskTierConfig(com.hazelcast.config.DiskTierConfig) IndexConfig(com.hazelcast.config.IndexConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) ItemListenerConfig(com.hazelcast.config.ItemListenerConfig) MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) CacheSimpleEntryListenerConfig(com.hazelcast.config.CacheSimpleEntryListenerConfig) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig) WanConsumerConfig(com.hazelcast.config.WanConsumerConfig) AttributeConfig(com.hazelcast.config.AttributeConfig) SetConfig(com.hazelcast.config.SetConfig) PNCounterConfig(com.hazelcast.config.PNCounterConfig) QueueConfig(com.hazelcast.config.QueueConfig) ListenerConfig(com.hazelcast.config.ListenerConfig) CardinalityEstimatorConfig(com.hazelcast.config.CardinalityEstimatorConfig) WanCustomPublisherConfig(com.hazelcast.config.WanCustomPublisherConfig) WanBatchPublisherConfig(com.hazelcast.config.WanBatchPublisherConfig) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) TieredStoreConfig(com.hazelcast.config.TieredStoreConfig) QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) ScheduledExecutorConfig(com.hazelcast.config.ScheduledExecutorConfig) TopicConfig(com.hazelcast.config.TopicConfig) Config(com.hazelcast.config.Config) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) DataPersistenceConfig(com.hazelcast.config.DataPersistenceConfig) DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig) MapPartitionLostListenerConfig(com.hazelcast.config.MapPartitionLostListenerConfig) WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) FlakeIdGeneratorConfig(com.hazelcast.config.FlakeIdGeneratorConfig) MerkleTreeConfig(com.hazelcast.config.MerkleTreeConfig) MemoryTierConfig(com.hazelcast.config.MemoryTierConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig)

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