use of com.hazelcast.config.RingbufferConfig in project hazelcast by hazelcast.
the class RingbufferTTLTest method whenTTLEnabled_thenVisibilityIsGuaranteed.
// if ttl is set, we need to make sure that during that period all items are accessible.
// In this particular test we set the ttl period to 10 second. The minimumVisibilitySeconds to
// give us an error margin of 2 seconds (due to threading etc... we don't want to have another
// spurious failing test.
@Test
public void whenTTLEnabled_thenVisibilityIsGuaranteed() {
int ttl = 10;
int minimumVisibleTTL = ttl - 2;
setup(new RingbufferConfig("foo").setTimeToLiveSeconds(ttl).setCapacity(100));
for (int k = 0; k < ringbuffer.capacity(); k++) {
ringbuffer.add("item" + k);
}
final long head = ringbuffer.headSequence();
final long tail = ringbuffer.tailSequence();
final long size = ringbuffer.size();
assertTrueAllTheTime(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(head, ringbuffer.headSequence());
assertEquals(tail, ringbuffer.tailSequence());
assertEquals(size, ringbuffer.size());
for (long seq = head; seq <= tail; seq++) {
assertEquals("item" + seq, ringbuffer.readOne(seq));
}
}
}, minimumVisibleTTL);
}
use of com.hazelcast.config.RingbufferConfig in project hazelcast by hazelcast.
the class StoreLatencyPluginRingbufferIntegrationTest method setup.
@Before
public void setup() throws Exception {
Config config = new Config().setProperty("hazelcast.diagnostics.enabled", "true").setProperty("hazelcast.diagnostics.storeLatency.period.seconds", "1");
RingbufferConfig rbConfig = addRingbufferConfig(config);
hz = createHazelcastInstance(config);
rb = hz.getRingbuffer(rbConfig.getName());
}
use of com.hazelcast.config.RingbufferConfig in project hazelcast by hazelcast.
the class ReliableTopicCreateTest method testWildcardConfig.
@Test
public void testWildcardConfig() {
Config config = new Config();
config.addRingBufferConfig(new RingbufferConfig("foo*").setCapacity(10));
config.addReliableTopicConfig(new ReliableTopicConfig("foo*").setTopicOverloadPolicy(DISCARD_NEWEST));
HazelcastInstance hz = createHazelcastInstance(config);
RingbufferService ringbufferService = getNodeEngineImpl(hz).getService(RingbufferService.SERVICE_NAME);
ReliableTopicProxy<String> topic = (ReliableTopicProxy<String>) hz.<String>getReliableTopic("foo");
Ringbuffer ringbuffer = topic.ringbuffer;
topic.publish("foo");
ReliableTopicProxy proxy = assertInstanceOf(ReliableTopicProxy.class, topic);
assertEquals(proxy.overloadPolicy, TopicOverloadPolicy.DISCARD_NEWEST);
final ConcurrentMap<Integer, Map<ObjectNamespace, RingbufferContainer>> containers = ringbufferService.getContainers();
assertEquals(1, containers.size());
final Map<ObjectNamespace, RingbufferContainer> partitionContainers = containers.get(ringbufferService.getRingbufferPartitionId(ringbuffer.getName()));
final ObjectNamespace ns = RingbufferService.getRingbufferNamespace(ringbuffer.getName());
assertTrue(partitionContainers.containsKey(ns));
assertEquals(0, ringbuffer.headSequence());
assertEquals(0, ringbuffer.tailSequence());
assertEquals(10, ringbuffer.capacity());
}
use of com.hazelcast.config.RingbufferConfig in project hazelcast by hazelcast.
the class ReliableTopicStressTest method setup.
@Before
public void setup() {
Config config = new Config();
RingbufferConfig ringbufferConfig = new RingbufferConfig("foobar");
ringbufferConfig.setCapacity(1000 * 1000);
ringbufferConfig.setTimeToLiveSeconds(5);
config.addRingBufferConfig(ringbufferConfig);
TopicConfig topicConfig = new TopicConfig("foobar");
config.addTopicConfig(topicConfig);
HazelcastInstance hz = createHazelcastInstance(config);
topic = hz.getReliableTopic(topicConfig.getName());
}
use of com.hazelcast.config.RingbufferConfig in project hazelcast by hazelcast.
the class LossToleranceTest method setup.
@Before
public void setup() {
Config config = smallInstanceConfig().addRingBufferConfig(new RingbufferConfig(RELIABLE_TOPIC_NAME).setCapacity(100).setTimeToLiveSeconds(0).setBackupCount(0).setAsyncBackupCount(0));
final HazelcastInstance[] instances = createHazelcastInstanceFactory(2).newInstances(config);
warmUpPartitions(instances);
for (HazelcastInstance instance : instances) {
final Member owner = instance.getPartitionService().getPartition(TOPIC_RB_PREFIX + RELIABLE_TOPIC_NAME).getOwner();
final Member localMember = instance.getCluster().getLocalMember();
if (localMember.equals(owner)) {
topicOwnerInstance = instance;
} else {
topicBackupInstance = instance;
}
}
topic = (ReliableTopicProxy<String>) topicBackupInstance.<String>getReliableTopic(RELIABLE_TOPIC_NAME);
ringbuffer = topic.ringbuffer;
}
Aggregations