use of com.hazelcast.config.CacheSimpleConfig in project hazelcast by hazelcast.
the class DynamicConfigYamlGenerator method cacheYamlGenerator.
public static void cacheYamlGenerator(Map<String, Object> parent, Config config) {
if (config.getCacheConfigs().isEmpty()) {
return;
}
Map<String, Object> child = new LinkedHashMap<>();
for (CacheSimpleConfig subConfigAsObject : config.getCacheConfigs().values()) {
Map<String, Object> subConfigAsMap = new LinkedHashMap<>();
addNonNullToMap(subConfigAsMap, "key-type", wrapObjectWithMap("class-name", subConfigAsObject.getKeyType()));
addNonNullToMap(subConfigAsMap, "value-type", wrapObjectWithMap("class-name", subConfigAsObject.getValueType()));
addNonNullToMap(subConfigAsMap, "statistics-enabled", subConfigAsObject.isStatisticsEnabled());
addNonNullToMap(subConfigAsMap, "management-enabled", subConfigAsObject.isManagementEnabled());
addNonNullToMap(subConfigAsMap, "read-through", subConfigAsObject.isReadThrough());
addNonNullToMap(subConfigAsMap, "write-through", subConfigAsObject.isWriteThrough());
addNonNullToMap(subConfigAsMap, "cache-loader-factory", wrapObjectWithMap("class-name", subConfigAsObject.getCacheLoaderFactory()));
addNonNullToMap(subConfigAsMap, "cache-writer-factory", wrapObjectWithMap("class-name", subConfigAsObject.getCacheWriterFactory()));
addNonNullToMap(subConfigAsMap, "cache-loader", wrapObjectWithMap("class-name", subConfigAsObject.getCacheLoader()));
addNonNullToMap(subConfigAsMap, "cache-writer", wrapObjectWithMap("class-name", subConfigAsObject.getCacheWriter()));
addNonNullToMap(subConfigAsMap, "expiry-policy-factory", getExpiryPolicyFactoryConfigAsMap(subConfigAsObject.getExpiryPolicyFactoryConfig()));
addNonNullToMap(subConfigAsMap, "cache-entry-listeners", getCacheSimpleEntryListenerConfigsAsList(subConfigAsObject.getCacheEntryListeners()));
addNonNullToMap(subConfigAsMap, "in-memory-format", subConfigAsObject.getInMemoryFormat().name());
addNonNullToMap(subConfigAsMap, "backup-count", subConfigAsObject.getBackupCount());
addNonNullToMap(subConfigAsMap, "async-backup-count", subConfigAsObject.getAsyncBackupCount());
addNonNullToMap(subConfigAsMap, "eviction", getEvictionConfigAsMap(subConfigAsObject.getEvictionConfig()));
addNonNullToMap(subConfigAsMap, "wan-replication-ref", getWanReplicationRefAsMap(subConfigAsObject.getWanReplicationRef(), false));
addNonNullToMap(subConfigAsMap, "split-brain-protection-ref", subConfigAsObject.getSplitBrainProtectionName());
addNonNullToMap(subConfigAsMap, "partition-lost-listeners", getListenerConfigsAsList(subConfigAsObject.getPartitionLostListenerConfigs()));
addNonNullToMap(subConfigAsMap, "merge-policy", getMergePolicyConfigAsMap(subConfigAsObject.getMergePolicyConfig()));
addNonNullToMap(subConfigAsMap, "event-journal", getEventJournalConfigAsMap(subConfigAsObject.getEventJournalConfig()));
addNonNullToMap(subConfigAsMap, "data-persistence", getDataPersistenceConfigAsMap(subConfigAsObject.getDataPersistenceConfig()));
addNonNullToMap(subConfigAsMap, "merkle-tree", getMerkleTreeConfigAsMap(subConfigAsObject.getMerkleTreeConfig()));
addNonNullToMap(subConfigAsMap, "disable-per-entry-invalidation-events", subConfigAsObject.isDisablePerEntryInvalidationEvents());
child.put(subConfigAsObject.getName(), subConfigAsMap);
}
parent.put("cache", child);
}
use of com.hazelcast.config.CacheSimpleConfig in project hazelcast by hazelcast.
the class DynamicConfigXmlGenerator method cacheXmlGenerator.
public static void cacheXmlGenerator(ConfigXmlGenerator.XmlGenerator gen, Config config) {
for (CacheSimpleConfig c : config.getCacheConfigs().values()) {
gen.open("cache", "name", c.getName());
if (c.getKeyType() != null) {
gen.node("key-type", null, "class-name", c.getKeyType());
}
if (c.getValueType() != null) {
gen.node("value-type", null, "class-name", c.getValueType());
}
gen.node("statistics-enabled", c.isStatisticsEnabled()).node("management-enabled", c.isManagementEnabled()).node("read-through", c.isReadThrough()).node("write-through", c.isWriteThrough());
checkAndFillCacheLoaderFactoryConfigXml(gen, c.getCacheLoaderFactory());
checkAndFillCacheLoaderConfigXml(gen, c.getCacheLoader());
checkAndFillCacheWriterFactoryConfigXml(gen, c.getCacheWriterFactory());
checkAndFillCacheWriterConfigXml(gen, c.getCacheWriter());
cacheExpiryPolicyFactoryConfigXmlGenerator(gen, c.getExpiryPolicyFactoryConfig());
gen.open("cache-entry-listeners");
for (CacheSimpleEntryListenerConfig el : c.getCacheEntryListeners()) {
gen.open("cache-entry-listener", "old-value-required", el.isOldValueRequired(), "synchronous", el.isSynchronous()).node("cache-entry-listener-factory", null, "class-name", el.getCacheEntryListenerFactory()).node("cache-entry-event-filter-factory", null, "class-name", el.getCacheEntryEventFilterFactory()).close();
}
gen.close().node("in-memory-format", c.getInMemoryFormat()).node("backup-count", c.getBackupCount()).node("async-backup-count", c.getAsyncBackupCount());
evictionConfigXmlGenerator(gen, c.getEvictionConfig());
wanReplicationConfigXmlGenerator(gen, c.getWanReplicationRef());
gen.node("split-brain-protection-ref", c.getSplitBrainProtectionName());
cachePartitionLostListenerConfigXmlGenerator(gen, c.getPartitionLostListenerConfigs());
gen.node("merge-policy", c.getMergePolicyConfig().getPolicy(), "batch-size", c.getMergePolicyConfig().getBatchSize());
appendEventJournalConfig(gen, c.getEventJournalConfig());
appendDataPersistenceConfig(gen, c.getDataPersistenceConfig());
if (c.getMerkleTreeConfig().getEnabled() != null) {
appendMerkleTreeConfig(gen, c.getMerkleTreeConfig());
}
gen.node("disable-per-entry-invalidation-events", c.isDisablePerEntryInvalidationEvents()).close();
}
}
use of com.hazelcast.config.CacheSimpleConfig 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.CacheSimpleConfig in project hazelcast by hazelcast.
the class CacheSplitBrainProtectionConfigTest method cacheConfigXmlTest.
@Test
public void cacheConfigXmlTest() throws IOException {
final String cacheName = "configtestCache" + randomString();
Config config = new XmlConfigBuilder(configUrl).build();
CacheSimpleConfig cacheConfig1 = config.getCacheConfig(cacheName);
final String splitBrainProtectionName = cacheConfig1.getSplitBrainProtectionName();
assertEquals("cache-split-brain-protection", splitBrainProtectionName);
SplitBrainProtectionConfig splitBrainProtectionConfig = config.getSplitBrainProtectionConfig(splitBrainProtectionName);
assertEquals(3, splitBrainProtectionConfig.getMinimumClusterSize());
assertEquals(SplitBrainProtectionOn.READ_WRITE, splitBrainProtectionConfig.getProtectOn());
}
use of com.hazelcast.config.CacheSimpleConfig in project hazelcast by hazelcast.
the class AdvancedCacheJournalTest method getConfig.
@Override
protected Config getConfig() {
CacheSimpleConfig cacheConfig = new CacheSimpleConfig().setName("*");
cacheConfig.getEvictionConfig().setSize(Integer.MAX_VALUE);
cacheConfig.setEventJournalConfig(new EventJournalConfig().setEnabled(true));
return super.getConfig().setProperty(ClusterProperty.PARTITION_COUNT.getName(), String.valueOf(PARTITION_COUNT)).addCacheConfig(cacheConfig);
}
Aggregations