use of com.hazelcast.config.RingbufferConfig 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.RingbufferConfig in project hazelcast by hazelcast.
the class ClusterWideConfigurationService method registerConfigLocally.
/**
* Register a dynamic configuration in a local member. When a dynamic configuration with the same name already
* exists then this call has no effect.
*
* @param newConfig Configuration to register.
* @param configCheckMode behaviour when a config is detected
* @throws UnsupportedOperationException when given configuration type is not supported
* @throws InvalidConfigurationException when conflict is detected and configCheckMode is on THROW_EXCEPTION
*/
@SuppressWarnings("checkstyle:methodlength")
public void registerConfigLocally(IdentifiedDataSerializable newConfig, ConfigCheckMode configCheckMode) {
IdentifiedDataSerializable currentConfig;
if (newConfig instanceof MultiMapConfig) {
MultiMapConfig multiMapConfig = (MultiMapConfig) newConfig;
currentConfig = multiMapConfigs.putIfAbsent(multiMapConfig.getName(), multiMapConfig);
} else if (newConfig instanceof MapConfig) {
MapConfig newMapConfig = (MapConfig) newConfig;
currentConfig = mapConfigs.putIfAbsent(newMapConfig.getName(), newMapConfig);
if (currentConfig == null) {
listener.onConfigRegistered(newMapConfig);
}
} else if (newConfig instanceof CardinalityEstimatorConfig) {
CardinalityEstimatorConfig cardinalityEstimatorConfig = (CardinalityEstimatorConfig) newConfig;
currentConfig = cardinalityEstimatorConfigs.putIfAbsent(cardinalityEstimatorConfig.getName(), cardinalityEstimatorConfig);
} else if (newConfig instanceof RingbufferConfig) {
RingbufferConfig ringbufferConfig = (RingbufferConfig) newConfig;
currentConfig = ringbufferConfigs.putIfAbsent(ringbufferConfig.getName(), ringbufferConfig);
} else if (newConfig instanceof ListConfig) {
ListConfig listConfig = (ListConfig) newConfig;
currentConfig = listConfigs.putIfAbsent(listConfig.getName(), listConfig);
} else if (newConfig instanceof SetConfig) {
SetConfig setConfig = (SetConfig) newConfig;
currentConfig = setConfigs.putIfAbsent(setConfig.getName(), setConfig);
} else if (newConfig instanceof ReplicatedMapConfig) {
ReplicatedMapConfig replicatedMapConfig = (ReplicatedMapConfig) newConfig;
currentConfig = replicatedMapConfigs.putIfAbsent(replicatedMapConfig.getName(), replicatedMapConfig);
} else if (newConfig instanceof TopicConfig) {
TopicConfig topicConfig = (TopicConfig) newConfig;
currentConfig = topicConfigs.putIfAbsent(topicConfig.getName(), topicConfig);
} else if (newConfig instanceof ExecutorConfig) {
ExecutorConfig executorConfig = (ExecutorConfig) newConfig;
currentConfig = executorConfigs.putIfAbsent(executorConfig.getName(), executorConfig);
} else if (newConfig instanceof DurableExecutorConfig) {
DurableExecutorConfig durableExecutorConfig = (DurableExecutorConfig) newConfig;
currentConfig = durableExecutorConfigs.putIfAbsent(durableExecutorConfig.getName(), durableExecutorConfig);
} else if (newConfig instanceof ScheduledExecutorConfig) {
ScheduledExecutorConfig scheduledExecutorConfig = (ScheduledExecutorConfig) newConfig;
currentConfig = scheduledExecutorConfigs.putIfAbsent(scheduledExecutorConfig.getName(), scheduledExecutorConfig);
} else if (newConfig instanceof QueueConfig) {
QueueConfig queueConfig = (QueueConfig) newConfig;
currentConfig = queueConfigs.putIfAbsent(queueConfig.getName(), queueConfig);
} else if (newConfig instanceof ReliableTopicConfig) {
ReliableTopicConfig reliableTopicConfig = (ReliableTopicConfig) newConfig;
currentConfig = reliableTopicConfigs.putIfAbsent(reliableTopicConfig.getName(), reliableTopicConfig);
} else if (newConfig instanceof CacheSimpleConfig) {
CacheSimpleConfig cacheSimpleConfig = (CacheSimpleConfig) newConfig;
currentConfig = cacheSimpleConfigs.putIfAbsent(cacheSimpleConfig.getName(), cacheSimpleConfig);
if (currentConfig == null) {
listener.onConfigRegistered(cacheSimpleConfig);
}
} else if (newConfig instanceof FlakeIdGeneratorConfig) {
FlakeIdGeneratorConfig config = (FlakeIdGeneratorConfig) newConfig;
currentConfig = flakeIdGeneratorConfigs.putIfAbsent(config.getName(), config);
} else if (newConfig instanceof PNCounterConfig) {
PNCounterConfig config = (PNCounterConfig) newConfig;
currentConfig = pnCounterConfigs.putIfAbsent(config.getName(), config);
} else {
throw new UnsupportedOperationException("Unsupported config type: " + newConfig);
}
checkCurrentConfigNullOrEqual(configCheckMode, currentConfig, newConfig);
persist(newConfig);
}
use of com.hazelcast.config.RingbufferConfig in project hazelcast by hazelcast.
the class RingbufferCacheEventJournalImpl method toRingbufferConfig.
/**
* {@inheritDoc}
*
* @throws CacheNotExistsException if the cache configuration was not found
*/
@Override
public RingbufferConfig toRingbufferConfig(EventJournalConfig config, ObjectNamespace namespace) {
CacheConfig cacheConfig = getCacheService().getCacheConfig(namespace.getObjectName());
if (cacheConfig == null) {
throw new CacheNotExistsException("Cache " + namespace.getObjectName() + " is already destroyed or not created yet, on " + nodeEngine.getLocalMember());
}
int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
return new RingbufferConfig().setAsyncBackupCount(cacheConfig.getAsyncBackupCount()).setBackupCount(cacheConfig.getBackupCount()).setInMemoryFormat(InMemoryFormat.OBJECT).setCapacity(config.getCapacity() / partitionCount).setTimeToLiveSeconds(config.getTimeToLiveSeconds());
}
use of com.hazelcast.config.RingbufferConfig 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.RingbufferConfig in project hazelcast by hazelcast.
the class AbstractSplitBrainProtectionTest method newRingbufferConfig.
protected static RingbufferConfig newRingbufferConfig(SplitBrainProtectionOn splitBrainProtectionOn, String splitBrainProtectionName) {
RingbufferConfig config = new RingbufferConfig(RINGBUFFER_NAME + splitBrainProtectionOn.name());
config.setSplitBrainProtectionName(splitBrainProtectionName);
config.setBackupCount(4);
return config;
}
Aggregations