Search in sources :

Example 6 with RingbufferService

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;
}
Also used : RingbufferContainer(com.hazelcast.ringbuffer.impl.RingbufferContainer) RingbufferService(com.hazelcast.ringbuffer.impl.RingbufferService)

Example 7 with RingbufferService

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());
}
Also used : Config(com.hazelcast.config.Config) RingbufferConfig(com.hazelcast.config.RingbufferConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) RingbufferService(com.hazelcast.ringbuffer.impl.RingbufferService) Before(org.junit.Before)

Example 8 with RingbufferService

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());
}
Also used : RingbufferConfig(com.hazelcast.config.RingbufferConfig) Config(com.hazelcast.config.Config) RingbufferConfig(com.hazelcast.config.RingbufferConfig) RingbufferService(com.hazelcast.ringbuffer.impl.RingbufferService) Before(org.junit.Before)

Example 9 with RingbufferService

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());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) ListenerConfig(com.hazelcast.config.ListenerConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) Config(com.hazelcast.config.Config) Ringbuffer(com.hazelcast.ringbuffer.Ringbuffer) RingbufferConfig(com.hazelcast.config.RingbufferConfig) RingbufferService(com.hazelcast.ringbuffer.impl.RingbufferService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 10 with RingbufferService

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());
}
Also used : Config(com.hazelcast.config.Config) RingbufferConfig(com.hazelcast.config.RingbufferConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) RingbufferService(com.hazelcast.ringbuffer.impl.RingbufferService) Before(org.junit.Before)

Aggregations

RingbufferService (com.hazelcast.ringbuffer.impl.RingbufferService)10 Config (com.hazelcast.config.Config)5 RingbufferConfig (com.hazelcast.config.RingbufferConfig)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 Ringbuffer (com.hazelcast.ringbuffer.Ringbuffer)4 RingbufferContainer (com.hazelcast.ringbuffer.impl.RingbufferContainer)4 ParallelTest (com.hazelcast.test.annotation.ParallelTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Test (org.junit.Test)4 Before (org.junit.Before)3 ListenerConfig (com.hazelcast.config.ListenerConfig)2 ReliableTopicConfig (com.hazelcast.config.ReliableTopicConfig)2 CardinalityEstimatorService (com.hazelcast.cardinality.impl.CardinalityEstimatorService)1 ListService (com.hazelcast.collection.impl.list.ListService)1 QueueService (com.hazelcast.collection.impl.queue.QueueService)1 SetService (com.hazelcast.collection.impl.set.SetService)1 AtomicLongService (com.hazelcast.concurrent.atomiclong.AtomicLongService)1 AtomicReferenceService (com.hazelcast.concurrent.atomicreference.AtomicReferenceService)1 CountDownLatchService (com.hazelcast.concurrent.countdownlatch.CountDownLatchService)1 IdGeneratorService (com.hazelcast.concurrent.idgen.IdGeneratorService)1