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());
}
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();
}
}
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;
}
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;
}
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);
}
Aggregations