Search in sources :

Example 1 with RingbufferConfig

use of com.hazelcast.config.RingbufferConfig in project hazelcast by hazelcast.

the class RingbufferAbstractTest method setup.

@Before
public void setup() {
    config = new Config();
    config.addRingBufferConfig(new RingbufferConfig("add_overwritingOldData*").setCapacity(5));
    config.addRingBufferConfig(new RingbufferConfig("add_manyTimesRoundTheRing*").setCapacity(5));
    config.addRingBufferConfig(new RingbufferConfig("readOne_whenBeforeHead*").setCapacity(5));
    config.addRingBufferConfig(new RingbufferConfig("readOne_whenObjectInMemoryFormat*").setCapacity(5).setInMemoryFormat(OBJECT));
    config.addRingBufferConfig(new RingbufferConfig("readManyAsync_whenEnoughItems_andObjectInMemoryFormat*").setCapacity(5).setInMemoryFormat(OBJECT));
    config.addRingBufferConfig(new RingbufferConfig("addAsync_whenOverwrite_andNoTTL*").setCapacity(300).setTimeToLiveSeconds(0));
    config.addRingBufferConfig(new RingbufferConfig("addAllAsync_whenCollectionExceedsCapacity*").setCapacity(5));
    config.addRingBufferConfig(new RingbufferConfig("addAllAsync_manyTimesRoundTheRing*").setCapacity(50));
    config.addRingBufferConfig(new RingbufferConfig("addAllAsync_whenObjectInMemoryFormat*").setCapacity(50).setInMemoryFormat(OBJECT));
    config.addRingBufferConfig(new RingbufferConfig("addAsync_fail_whenNoSpace*").setCapacity(300).setTimeToLiveSeconds(10));
    config.addRingBufferConfig(new RingbufferConfig("addAsync_whenOverwrite_andTTL*").setCapacity(300));
    config.addRingBufferConfig(new RingbufferConfig("addAsync_whenOverwrite_andNoTTL*").setCapacity(300).setTimeToLiveSeconds(0));
    config.addRingBufferConfig(new RingbufferConfig("remainingCapacity*").setCapacity(300).setTimeToLiveSeconds(10));
    config.addRingBufferConfig(new RingbufferConfig("readOne_staleSequence*").setCapacity(5));
    config.addRingBufferConfig(new RingbufferConfig("readOne_futureSequence*").setCapacity(5));
    instances = newInstances(config);
    local = instances[0];
    HazelcastInstance target = instances[instances.length - 1];
    name = HazelcastTestSupport.randomNameOwnedBy(target, getTestMethodName());
    ringbuffer = local.getRingbuffer(name);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) RingbufferConfig(com.hazelcast.config.RingbufferConfig) Config(com.hazelcast.config.Config) RingbufferConfig(com.hazelcast.config.RingbufferConfig) Before(org.junit.Before)

Example 2 with RingbufferConfig

use of com.hazelcast.config.RingbufferConfig in project hazelcast by hazelcast.

the class RingbufferService method getContainer.

public RingbufferContainer getContainer(String name) {
    RingbufferContainer ringbuffer = containers.get(name);
    if (ringbuffer != null) {
        return ringbuffer;
    }
    RingbufferConfig ringbufferConfig = getRingbufferConfig(name);
    ringbuffer = new RingbufferContainer(name, ringbufferConfig, nodeEngine.getSerializationService(), nodeEngine.getConfigClassLoader());
    ringbuffer.getStore().instrument(nodeEngine);
    containers.put(name, ringbuffer);
    return ringbuffer;
}
Also used : RingbufferConfig(com.hazelcast.config.RingbufferConfig)

Example 3 with RingbufferConfig

use of com.hazelcast.config.RingbufferConfig in project hazelcast by hazelcast.

the class RingbufferService method addRingbuffer.

public void addRingbuffer(String name, RingbufferContainer ringbuffer) {
    checkNotNull(name, "name can't be null");
    checkNotNull(ringbuffer, "ringbuffer can't be null");
    final RingbufferConfig config = nodeEngine.getConfig().getRingbufferConfig(name);
    final SerializationService serializationService = nodeEngine.getSerializationService();
    ringbuffer.init(name, config, serializationService, nodeEngine.getConfigClassLoader());
    ringbuffer.getStore().instrument(nodeEngine);
    containers.put(name, ringbuffer);
}
Also used : RingbufferConfig(com.hazelcast.config.RingbufferConfig) SerializationService(com.hazelcast.spi.serialization.SerializationService)

Example 4 with RingbufferConfig

use of com.hazelcast.config.RingbufferConfig in project hazelcast by hazelcast.

the class RingbufferTest method init.

@Before
public void init() {
    Config config = new Config();
    config.addRingBufferConfig(new RingbufferConfig("rb*").setCapacity(CAPACITY));
    // Set operation timeout to larger than test timeout. So the tests do not pass accidentally because of retries.
    // The tests should depend on notifier system, not retrying.
    config.setProperty("hazelcast.operation.call.timeout.millis", "305000");
    config.getSerializationConfig().addDataSerializableFactory(IdentifiedDataSerializableFactory.FACTORY_ID, new IdentifiedDataSerializableFactory());
    server = hazelcastFactory.newHazelcastInstance(config);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.getSerializationConfig().addDataSerializableFactory(IdentifiedDataSerializableFactory.FACTORY_ID, new IdentifiedDataSerializableFactory());
    client = hazelcastFactory.newHazelcastClient(clientConfig);
    String name = "rb-" + randomString();
    serverRingbuffer = server.getRingbuffer(name);
    clientRingbuffer = client.getRingbuffer(name);
}
Also used : IdentifiedDataSerializableFactory(com.hazelcast.client.test.IdentifiedDataSerializableFactory) RingbufferConfig(com.hazelcast.config.RingbufferConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) RingbufferConfig(com.hazelcast.config.RingbufferConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Before(org.junit.Before)

Example 5 with RingbufferConfig

use of com.hazelcast.config.RingbufferConfig in project hazelcast by hazelcast.

the class ClientReliableTopicOverloadTest method setupCluster.

@Before
public void setupCluster() {
    Config config = new Config();
    config.addRingBufferConfig(new RingbufferConfig("when*").setCapacity(100).setTimeToLiveSeconds(Integer.MAX_VALUE));
    hazelcastFactory.newHazelcastInstance(config);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.addReliableTopicConfig(new ClientReliableTopicConfig("whenError_*").setTopicOverloadPolicy(TopicOverloadPolicy.ERROR));
    clientConfig.addReliableTopicConfig(new ClientReliableTopicConfig("whenDiscardOldest_*").setTopicOverloadPolicy(TopicOverloadPolicy.DISCARD_OLDEST));
    clientConfig.addReliableTopicConfig(new ClientReliableTopicConfig("whenDiscardNewest_*").setTopicOverloadPolicy(TopicOverloadPolicy.DISCARD_NEWEST));
    clientConfig.addReliableTopicConfig(new ClientReliableTopicConfig("whenBlock_*").setTopicOverloadPolicy(TopicOverloadPolicy.BLOCK));
    HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
    serializationService = ((HazelcastClientProxy) client).getSerializationService();
    String topicName = getTestMethodName();
    topic = client.<String>getReliableTopic(topicName);
    ringbuffer = ((ClientReliableTopicProxy<String>) topic).getRingbuffer();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientReliableTopicConfig(com.hazelcast.client.config.ClientReliableTopicConfig) Config(com.hazelcast.config.Config) RingbufferConfig(com.hazelcast.config.RingbufferConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) ClientReliableTopicConfig(com.hazelcast.client.config.ClientReliableTopicConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Before(org.junit.Before)

Aggregations

RingbufferConfig (com.hazelcast.config.RingbufferConfig)91 Test (org.junit.Test)43 Config (com.hazelcast.config.Config)35 QuickTest (com.hazelcast.test.annotation.QuickTest)26 HazelcastInstance (com.hazelcast.core.HazelcastInstance)22 Before (org.junit.Before)21 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)14 NightlyTest (com.hazelcast.test.annotation.NightlyTest)12 ReliableTopicConfig (com.hazelcast.config.ReliableTopicConfig)11 RingbufferStoreConfig (com.hazelcast.config.RingbufferStoreConfig)9 Data (com.hazelcast.internal.serialization.Data)7 TopicConfig (com.hazelcast.config.TopicConfig)6 ClientConfig (com.hazelcast.client.config.ClientConfig)5 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)5 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)5 DurableExecutorConfig (com.hazelcast.config.DurableExecutorConfig)5 ExecutorConfig (com.hazelcast.config.ExecutorConfig)5 FlakeIdGeneratorConfig (com.hazelcast.config.FlakeIdGeneratorConfig)5 ListConfig (com.hazelcast.config.ListConfig)5 MapConfig (com.hazelcast.config.MapConfig)5