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]);
}
}
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();
}
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());
}
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);
}
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);
}
Aggregations