Search in sources :

Example 1 with RingbufferStoreConfig

use of com.hazelcast.config.RingbufferStoreConfig 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 2 with RingbufferStoreConfig

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

the class DynamicConfigXmlGenerator method ringbufferXmlGenerator.

public static void ringbufferXmlGenerator(ConfigXmlGenerator.XmlGenerator gen, Config config) {
    Collection<RingbufferConfig> configs = config.getRingbufferConfigs().values();
    for (RingbufferConfig rbConfig : configs) {
        gen.open("ringbuffer", "name", rbConfig.getName()).node("capacity", rbConfig.getCapacity()).node("time-to-live-seconds", rbConfig.getTimeToLiveSeconds()).node("backup-count", rbConfig.getBackupCount()).node("async-backup-count", rbConfig.getAsyncBackupCount()).node("split-brain-protection-ref", rbConfig.getSplitBrainProtectionName()).node("in-memory-format", rbConfig.getInMemoryFormat());
        RingbufferStoreConfig storeConfig = rbConfig.getRingbufferStoreConfig();
        if (storeConfig != null) {
            gen.open("ringbuffer-store", "enabled", storeConfig.isEnabled()).node("class-name", classNameOrImplClass(storeConfig.getClassName(), storeConfig.getStoreImplementation())).node("factory-class-name", classNameOrImplClass(storeConfig.getFactoryClassName(), storeConfig.getFactoryImplementation())).appendProperties(storeConfig.getProperties());
            gen.close();
        }
        MergePolicyConfig mergePolicyConfig = rbConfig.getMergePolicyConfig();
        gen.node("merge-policy", mergePolicyConfig.getPolicy(), "batch-size", mergePolicyConfig.getBatchSize()).close();
    }
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig)

Example 3 with RingbufferStoreConfig

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

the class ClientDynamicClusterConfig method addRingBufferConfig.

@Override
public Config addRingBufferConfig(RingbufferConfig ringbufferConfig) {
    RingbufferStoreConfigHolder ringbufferStoreConfig = null;
    if (ringbufferConfig.getRingbufferStoreConfig() != null && ringbufferConfig.getRingbufferStoreConfig().isEnabled()) {
        RingbufferStoreConfig storeConfig = ringbufferConfig.getRingbufferStoreConfig();
        ringbufferStoreConfig = RingbufferStoreConfigHolder.of(storeConfig, instance.getSerializationService());
    }
    ClientMessage request = DynamicConfigAddRingbufferConfigCodec.encodeRequest(ringbufferConfig.getName(), ringbufferConfig.getCapacity(), ringbufferConfig.getBackupCount(), ringbufferConfig.getAsyncBackupCount(), ringbufferConfig.getTimeToLiveSeconds(), ringbufferConfig.getInMemoryFormat().name(), ringbufferStoreConfig, ringbufferConfig.getSplitBrainProtectionName(), ringbufferConfig.getMergePolicyConfig().getPolicy(), ringbufferConfig.getMergePolicyConfig().getBatchSize());
    invoke(request);
    return this;
}
Also used : RingbufferStoreConfigHolder(com.hazelcast.client.impl.protocol.task.dynamicconfig.RingbufferStoreConfigHolder) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage)

Example 4 with RingbufferStoreConfig

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

the class AddRingbufferConfigMessageTask method getConfig.

@Override
protected IdentifiedDataSerializable getConfig() {
    RingbufferConfig config = new RingbufferConfig(parameters.name);
    config.setAsyncBackupCount(parameters.asyncBackupCount);
    config.setBackupCount(parameters.backupCount);
    config.setCapacity(parameters.capacity);
    config.setInMemoryFormat(InMemoryFormat.valueOf(parameters.inMemoryFormat));
    config.setTimeToLiveSeconds(parameters.timeToLiveSeconds);
    if (parameters.ringbufferStoreConfig != null) {
        RingbufferStoreConfig storeConfig = parameters.ringbufferStoreConfig.asRingbufferStoreConfig(serializationService);
        config.setRingbufferStoreConfig(storeConfig);
    }
    MergePolicyConfig mergePolicyConfig = mergePolicyConfig(parameters.mergePolicy, parameters.mergeBatchSize);
    config.setMergePolicyConfig(mergePolicyConfig);
    return config;
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig)

Example 5 with RingbufferStoreConfig

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

the class MemberDomConfigProcessor method handleRingBufferNode.

void handleRingBufferNode(Node node, RingbufferConfig rbConfig) {
    for (Node n : childElements(node)) {
        String nodeName = cleanNodeName(n);
        if (matches("capacity", nodeName)) {
            int capacity = getIntegerValue("capacity", getTextContent(n));
            rbConfig.setCapacity(capacity);
        } else if (matches("backup-count", nodeName)) {
            int backupCount = getIntegerValue("backup-count", getTextContent(n));
            rbConfig.setBackupCount(backupCount);
        } else if (matches("async-backup-count", nodeName)) {
            int asyncBackupCount = getIntegerValue("async-backup-count", getTextContent(n));
            rbConfig.setAsyncBackupCount(asyncBackupCount);
        } else if (matches("time-to-live-seconds", nodeName)) {
            int timeToLiveSeconds = getIntegerValue("time-to-live-seconds", getTextContent(n));
            rbConfig.setTimeToLiveSeconds(timeToLiveSeconds);
        } else if (matches("in-memory-format", nodeName)) {
            InMemoryFormat inMemoryFormat = InMemoryFormat.valueOf(upperCaseInternal(getTextContent(n)));
            rbConfig.setInMemoryFormat(inMemoryFormat);
        } else if (matches("ringbuffer-store", nodeName)) {
            RingbufferStoreConfig ringbufferStoreConfig = createRingbufferStoreConfig(n);
            rbConfig.setRingbufferStoreConfig(ringbufferStoreConfig);
        } else if (matches("split-brain-protection-ref", nodeName)) {
            rbConfig.setSplitBrainProtectionName(getTextContent(n));
        } else if (matches("merge-policy", nodeName)) {
            MergePolicyConfig mpConfig = createMergePolicyConfig(n, rbConfig.getMergePolicyConfig());
            rbConfig.setMergePolicyConfig(mpConfig);
        }
    }
    config.addRingBufferConfig(rbConfig);
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) Node(org.w3c.dom.Node) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig) InMemoryFormat(com.hazelcast.config.InMemoryFormat)

Aggregations

RingbufferStoreConfig (com.hazelcast.config.RingbufferStoreConfig)28 RingbufferConfig (com.hazelcast.config.RingbufferConfig)19 Config (com.hazelcast.config.Config)16 Test (org.junit.Test)16 HazelcastInstance (com.hazelcast.core.HazelcastInstance)12 QuickTest (com.hazelcast.test.annotation.QuickTest)12 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)11 MergePolicyConfig (com.hazelcast.config.MergePolicyConfig)7 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 AttributeConfig (com.hazelcast.config.AttributeConfig)2 AwsConfig (com.hazelcast.config.AwsConfig)2 CachePartitionLostListenerConfig (com.hazelcast.config.CachePartitionLostListenerConfig)2 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)2 CacheSimpleEntryListenerConfig (com.hazelcast.config.CacheSimpleEntryListenerConfig)2 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)2 DataPersistenceConfig (com.hazelcast.config.DataPersistenceConfig)2 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)2 DiscoveryStrategyConfig (com.hazelcast.config.DiscoveryStrategyConfig)2 DiskTierConfig (com.hazelcast.config.DiskTierConfig)2