use of com.hazelcast.ringbuffer.Ringbuffer in project hazelcast by hazelcast.
the class PartitionControlledIdTest method testRingbuffer.
@Test
public void testRingbuffer() throws Exception {
String partitionKey = "hazelcast";
HazelcastInstance hz = getHazelcastInstance(partitionKey);
Ringbuffer ringbuffer = hz.getRingbuffer("ringbuffer@" + partitionKey);
ringbuffer.add("foo");
assertEquals("ringbuffer@" + partitionKey, ringbuffer.getName());
assertEquals(partitionKey, ringbuffer.getPartitionKey());
RingbufferService service = getNodeEngine(hz).getService(RingbufferService.SERVICE_NAME);
assertTrue(service.getContainers().containsKey(ringbuffer.getName()));
}
use of com.hazelcast.ringbuffer.Ringbuffer in project hazelcast by hazelcast.
the class HazelcastOSGiInstanceTest method getRingbufferCalledSuccessfullyOverOSGiInstance.
@Test
public void getRingbufferCalledSuccessfullyOverOSGiInstance() {
Ringbuffer mockRingbuffer = mock(Ringbuffer.class);
HazelcastInstance mockHazelcastInstance = mock(HazelcastInstance.class);
HazelcastOSGiInstance hazelcastOSGiInstance = HazelcastOSGiTestUtil.createHazelcastOSGiInstance(mockHazelcastInstance);
when(mockHazelcastInstance.getRingbuffer("my-ringbuffer")).thenReturn(mockRingbuffer);
assertEquals(mockRingbuffer, hazelcastOSGiInstance.getRingbuffer("my-ringbuffer"));
verify(mockHazelcastInstance).getRingbuffer("my-ringbuffer");
}
use of com.hazelcast.ringbuffer.Ringbuffer in project hazelcast by hazelcast.
the class RingbufferServiceTest method rollbackMigration.
@Test
public void rollbackMigration() {
Ringbuffer ringbuffer = hz.getRingbuffer("foo");
int partitionId = getPartitionId(hz, ringbuffer.getName());
PartitionMigrationEvent partitionEvent = new PartitionMigrationEvent(DESTINATION, partitionId, -1, 0);
service.rollbackMigration(partitionEvent);
assertEquals(0, service.getContainers().size());
}
use of com.hazelcast.ringbuffer.Ringbuffer 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.Ringbuffer 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());
}
Aggregations