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