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