Search in sources :

Example 6 with RingbufferConfig

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

the class Issue7317Test method setup.

@Before
public void setup() {
    Config serverConfig = new Config();
    RingbufferConfig rbConf = new RingbufferConfig(smallRB);
    rbConf.setCapacity(smallRBCapacity);
    serverConfig.addRingBufferConfig(rbConf);
    hazelcastFactory.newHazelcastInstance(serverConfig);
    ClientConfig config = new ClientConfig();
    config.getReliableTopicConfig(smallRB).setReadBatchSize(smallRBCapacity);
    client = hazelcastFactory.newHazelcastClient(config);
}
Also used : Config(com.hazelcast.config.Config) RingbufferConfig(com.hazelcast.config.RingbufferConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Before(org.junit.Before)

Example 7 with RingbufferConfig

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

the class ClientReliableTopicBlockTest method setup.

@Before
public void setup() {
    Config config = smallInstanceConfig();
    config.addRingBufferConfig(new RingbufferConfig("blockingReliableTopic*").setCapacity(10).setTimeToLiveSeconds(60));
    hazelcastFactory.newHazelcastInstance(config);
    ClientConfig clientConfig = new ClientConfig().addReliableTopicConfig(new ClientReliableTopicConfig("blockingReliableTopic*").setReadBatchSize(10).setTopicOverloadPolicy(TopicOverloadPolicy.BLOCK));
    client = hazelcastFactory.newHazelcastClient(clientConfig);
}
Also used : 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)

Example 8 with RingbufferConfig

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

the class TestFullApplicationContext method testRingbufferConfig.

@Test
public void testRingbufferConfig() {
    RingbufferConfig testRingbuffer = config.getRingbufferConfig("testRingbuffer");
    assertNotNull(testRingbuffer);
    assertEquals("testRingbuffer", testRingbuffer.getName());
    assertEquals(InMemoryFormat.OBJECT, testRingbuffer.getInMemoryFormat());
    assertEquals(100, testRingbuffer.getCapacity());
    assertEquals(1, testRingbuffer.getBackupCount());
    assertEquals(1, testRingbuffer.getAsyncBackupCount());
    assertEquals(20, testRingbuffer.getTimeToLiveSeconds());
    RingbufferStoreConfig store1 = testRingbuffer.getRingbufferStoreConfig();
    assertNotNull(store1);
    assertEquals(DummyRingbufferStore.class.getName(), store1.getClassName());
    MergePolicyConfig mergePolicyConfig = testRingbuffer.getMergePolicyConfig();
    assertNotNull(mergePolicyConfig);
    assertEquals("PassThroughMergePolicy", mergePolicyConfig.getPolicy());
    assertEquals(2342, mergePolicyConfig.getBatchSize());
    RingbufferConfig testRingbuffer2 = config.getRingbufferConfig("testRingbuffer2");
    assertNotNull(testRingbuffer2);
    RingbufferStoreConfig store2 = testRingbuffer2.getRingbufferStoreConfig();
    assertNotNull(store2);
    assertEquals(DummyRingbufferStoreFactory.class.getName(), store2.getFactoryClassName());
    assertFalse(store2.getProperties().isEmpty());
    assertEquals("value", store2.getProperty("dummy.property"));
    assertEquals("value2", store2.getProperty("dummy.property.2"));
    RingbufferConfig testRingbuffer3 = config.getRingbufferConfig("testRingbuffer3");
    assertNotNull(testRingbuffer3);
    RingbufferStoreConfig store3 = testRingbuffer3.getRingbufferStoreConfig();
    assertNotNull(store3);
    assertEquals(dummyRingbufferStore, store3.getStoreImplementation());
    RingbufferConfig testRingbuffer4 = config.getRingbufferConfig("testRingbuffer4");
    assertNotNull(testRingbuffer4);
    RingbufferStoreConfig store4 = testRingbuffer4.getRingbufferStoreConfig();
    assertNotNull(store4);
    assertEquals(dummyRingbufferStoreFactory, store4.getFactoryImplementation());
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 9 with RingbufferConfig

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

the class RingbufferService method createDistributedObject.

@Override
public DistributedObject createDistributedObject(String objectName, UUID source, boolean local) {
    RingbufferConfig ringbufferConfig = getRingbufferConfig(objectName);
    checkRingbufferConfig(ringbufferConfig, nodeEngine.getSplitBrainMergePolicyProvider());
    return new RingbufferProxy(nodeEngine, this, objectName, ringbufferConfig);
}
Also used : ConfigValidator.checkRingbufferConfig(com.hazelcast.internal.config.ConfigValidator.checkRingbufferConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig)

Example 10 with RingbufferConfig

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

the class MergeOperation method merge.

/**
 * Merges the provided {@code mergingValue} into the {@code existingContainer}
 * and returns the merged ringbuffer.
 *
 * @param existingContainer the container into which to merge the data
 * @param mergingValue      the data to merge
 * @return the merged ringbuffer
 */
private Ringbuffer<Object> merge(RingbufferContainer<Object, Object> existingContainer, RingbufferMergeTypes mergingValue) {
    RingbufferMergeTypes existingValue = createMergingValueOrNull(existingContainer);
    RingbufferMergeData resultData = mergePolicy.merge(mergingValue, existingValue);
    if (resultData == null) {
        ringbufferService.destroyDistributedObject(namespace.getObjectName());
        return null;
    } else {
        if (existingContainer == null) {
            RingbufferConfig config = getRingbufferConfig(ringbufferService, namespace);
            existingContainer = ringbufferService.getOrCreateContainer(getPartitionId(), namespace, config);
        }
        setRingbufferData(resultData, existingContainer);
        return existingContainer.getRingbuffer();
    }
}
Also used : RingbufferMergeTypes(com.hazelcast.spi.merge.SplitBrainMergeTypes.RingbufferMergeTypes) RingbufferMergeData(com.hazelcast.spi.merge.RingbufferMergeData) RingbufferConfig(com.hazelcast.config.RingbufferConfig)

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