use of com.hazelcast.ringbuffer.impl.RingbufferService in project hazelcast by hazelcast.
the class AbstractRingBufferOperation method getRingBufferContainer.
/**
* Returns an {@link RingbufferContainer} or creates a new one if necessary by calling
* {@link RingbufferService#getContainer(String)}. Also calls the {@link RingbufferContainer#cleanup()} before returning
* the container. This will currently remove any expired items.
*
* @return the ring buffer container
*/
RingbufferContainer getRingBufferContainer() {
if (ringbuffer != null) {
return ringbuffer;
}
RingbufferService service = getService();
RingbufferContainer ringbuffer = service.getContainer(name);
ringbuffer.cleanup();
this.ringbuffer = ringbuffer;
return ringbuffer;
}
use of com.hazelcast.ringbuffer.impl.RingbufferService in project hazelcast by hazelcast.
the class GenericOperationTest method setup.
@Before
public void setup() {
RingbufferConfig rbConfig = new RingbufferConfig("foo").setCapacity(CAPACITY).setTimeToLiveSeconds(10);
Config config = new Config().addRingBufferConfig(rbConfig);
hz = createHazelcastInstance(config);
nodeEngine = getNodeEngineImpl(hz);
serializationService = nodeEngine.getSerializationService();
ringbuffer = hz.getRingbuffer(rbConfig.getName());
RingbufferService ringbufferService = getNodeEngineImpl(hz).getService(RingbufferService.SERVICE_NAME);
ringbufferContainer = ringbufferService.getContainer(rbConfig.getName());
}
use of com.hazelcast.ringbuffer.impl.RingbufferService in project hazelcast by hazelcast.
the class ReadManyOperationTest method setup.
@Before
public void setup() {
RingbufferConfig rbConfig = new RingbufferConfig("foo").setCapacity(10).setTimeToLiveSeconds(10);
Config config = new Config().addRingBufferConfig(rbConfig);
hz = createHazelcastInstance(config);
nodeEngine = getNodeEngineImpl(hz);
serializationService = nodeEngine.getSerializationService();
ringbuffer = hz.getRingbuffer(rbConfig.getName());
RingbufferService ringbufferService = getNodeEngineImpl(hz).getService(RingbufferService.SERVICE_NAME);
ringbufferContainer = ringbufferService.getContainer(rbConfig.getName());
}
use of com.hazelcast.ringbuffer.impl.RingbufferService 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);
assertEquals(1, ringbufferService.getContainers().size());
assertTrue(ringbufferService.getContainers().containsKey(ringbuffer.getName()));
assertEquals(0, ringbuffer.headSequence());
assertEquals(0, ringbuffer.tailSequence());
assertEquals(10, ringbuffer.capacity());
}
use of com.hazelcast.ringbuffer.impl.RingbufferService in project hazelcast by hazelcast.
the class ReadOneOperationTest method setup.
@Before
public void setup() {
RingbufferConfig rbConfig = new RingbufferConfig("foo").setCapacity(10).setTimeToLiveSeconds(10);
Config config = new Config().addRingBufferConfig(rbConfig);
hz = createHazelcastInstance(config);
nodeEngine = getNodeEngineImpl(hz);
serializationService = getSerializationService(hz);
ringbuffer = hz.getRingbuffer(rbConfig.getName());
RingbufferService ringbufferService = getNodeEngineImpl(hz).getService(RingbufferService.SERVICE_NAME);
ringbufferContainer = ringbufferService.getContainer(rbConfig.getName());
}
Aggregations