use of com.hazelcast.ringbuffer.impl.RingbufferContainer in project hazelcast by hazelcast.
the class ReplicationOperation method run.
@Override
public void run() {
RingbufferService service = getService();
for (Map.Entry<String, RingbufferContainer> entry : migrationData.entrySet()) {
String name = entry.getKey();
RingbufferContainer ringbuffer = entry.getValue();
service.addRingbuffer(name, ringbuffer);
}
}
use of com.hazelcast.ringbuffer.impl.RingbufferContainer in project hazelcast by hazelcast.
the class ReplicationOperation method readInternal.
@Override
protected void readInternal(ObjectDataInput in) throws IOException {
int mapSize = in.readInt();
migrationData = new HashMap<String, RingbufferContainer>(mapSize);
for (int i = 0; i < mapSize; i++) {
String name = in.readUTF();
RingbufferContainer container = new RingbufferContainer(name);
container.readData(in);
migrationData.put(name, container);
}
}
use of com.hazelcast.ringbuffer.impl.RingbufferContainer in project hazelcast by hazelcast.
the class ReliableTopicCreateTest method testConstruction.
@Test
public void testConstruction() {
HazelcastInstance hz = createHazelcastInstance();
RingbufferService ringbufferService = getNodeEngineImpl(hz).getService(RingbufferService.SERVICE_NAME);
ReliableTopicProxy<String> topic = (ReliableTopicProxy<String>) hz.<String>getReliableTopic("foo");
Ringbuffer ringbuffer = hz.getRingbuffer(RingbufferService.TOPIC_RB_PREFIX + "foo");
assertSame(ringbuffer, topic.ringbuffer);
// make sure the ringbuffer and topic are hooked up correctly
topic.publish("item1");
topic.publish("item2");
assertEquals(0, ringbuffer.headSequence());
assertEquals(1, ringbuffer.tailSequence());
ConcurrentMap<String, RingbufferContainer> containers = ringbufferService.getContainers();
assertEquals(1, containers.size());
assertTrue(containers.containsKey(ringbuffer.getName()));
}
use of com.hazelcast.ringbuffer.impl.RingbufferContainer in project hazelcast by hazelcast.
the class ReliableTopicCreateTest method testRingbufferConfiguration.
@Test
public void testRingbufferConfiguration() {
Config config = new Config();
RingbufferConfig rbConfig = new RingbufferConfig("foo").setCapacity(21);
config.addRingBufferConfig(rbConfig);
HazelcastInstance hz = createHazelcastInstance(config);
RingbufferService ringbufferService = getNodeEngineImpl(hz).getService(RingbufferService.SERVICE_NAME);
ReliableTopicProxy topic = (ReliableTopicProxy) hz.getReliableTopic("foo");
Ringbuffer ringbuffer = hz.getRingbuffer(RingbufferService.TOPIC_RB_PREFIX + "foo");
assertSame(ringbuffer, topic.ringbuffer);
assertEquals(21, ringbuffer.capacity());
// triggers the creation
ringbuffer.size();
ConcurrentMap<String, RingbufferContainer> containers = ringbufferService.getContainers();
assertEquals(1, containers.size());
assertTrue(containers.containsKey(ringbuffer.getName()));
RingbufferContainer container = containers.get(ringbuffer.getName());
assertEquals(rbConfig.getCapacity(), container.getConfig().getCapacity());
}
use of com.hazelcast.ringbuffer.impl.RingbufferContainer 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;
}
Aggregations