use of com.hazelcast.config.MergePolicyConfig in project hazelcast by hazelcast.
the class DynamicConfigXmlGenerator method mapXmlGenerator.
public static void mapXmlGenerator(ConfigXmlGenerator.XmlGenerator gen, Config config) {
Collection<MapConfig> mapConfigs = config.getMapConfigs().values();
for (MapConfig m : mapConfigs) {
String cacheDeserializedVal = m.getCacheDeserializedValues() != null ? m.getCacheDeserializedValues().name().replaceAll("_", "-") : null;
MergePolicyConfig mergePolicyConfig = m.getMergePolicyConfig();
gen.open("map", "name", m.getName()).node("in-memory-format", m.getInMemoryFormat()).node("statistics-enabled", m.isStatisticsEnabled()).node("per-entry-stats-enabled", m.isPerEntryStatsEnabled()).node("cache-deserialized-values", cacheDeserializedVal).node("backup-count", m.getBackupCount()).node("async-backup-count", m.getAsyncBackupCount()).node("time-to-live-seconds", m.getTimeToLiveSeconds()).node("max-idle-seconds", m.getMaxIdleSeconds()).node("merge-policy", mergePolicyConfig.getPolicy(), "batch-size", mergePolicyConfig.getBatchSize()).node("split-brain-protection-ref", m.getSplitBrainProtectionName()).node("read-backup-data", m.isReadBackupData()).node("metadata-policy", m.getMetadataPolicy());
evictionConfigXmlGenerator(gen, m.getEvictionConfig());
if (m.getMerkleTreeConfig().getEnabled() != null) {
appendMerkleTreeConfig(gen, m.getMerkleTreeConfig());
}
appendEventJournalConfig(gen, m.getEventJournalConfig());
appendDataPersistenceConfig(gen, m.getDataPersistenceConfig());
mapStoreConfigXmlGenerator(gen, m);
mapNearCacheConfigXmlGenerator(gen, m.getNearCacheConfig());
wanReplicationConfigXmlGenerator(gen, m.getWanReplicationRef());
indexConfigXmlGenerator(gen, m);
attributeConfigXmlGenerator(gen, m);
entryListenerConfigXmlGenerator(gen, m);
mapPartitionLostListenerConfigXmlGenerator(gen, m);
mapPartitionStrategyConfigXmlGenerator(gen, m);
mapQueryCachesConfigXmlGenerator(gen, m);
tieredStoreConfigXmlGenerator(gen, m.getTieredStoreConfig());
gen.close();
}
}
use of com.hazelcast.config.MergePolicyConfig in project hazelcast by hazelcast.
the class DynamicConfigXmlGenerator method collectionXmlGenerator.
@SuppressWarnings("unchecked")
private static void collectionXmlGenerator(ConfigXmlGenerator.XmlGenerator gen, String type, Collection<? extends CollectionConfig> configs) {
if (CollectionUtil.isNotEmpty(configs)) {
for (CollectionConfig<? extends CollectionConfig> config : configs) {
gen.open(type, "name", config.getName()).node("statistics-enabled", config.isStatisticsEnabled()).node("max-size", config.getMaxSize()).node("backup-count", config.getBackupCount()).node("async-backup-count", config.getAsyncBackupCount()).node("split-brain-protection-ref", config.getSplitBrainProtectionName());
appendItemListenerConfigs(gen, config.getItemListenerConfigs());
MergePolicyConfig mergePolicyConfig = config.getMergePolicyConfig();
gen.node("merge-policy", mergePolicyConfig.getPolicy(), "batch-size", mergePolicyConfig.getBatchSize()).close();
}
}
}
use of com.hazelcast.config.MergePolicyConfig in project hazelcast by hazelcast.
the class AbstractDynamicConfigGeneratorTest method testSet.
// LIST
@Test
public void testSet() {
MergePolicyConfig mergePolicyConfig = new MergePolicyConfig().setPolicy(LatestUpdateMergePolicy.class.getName()).setBatchSize(1234);
SetConfig expectedConfig = new SetConfig("testSet").setMaxSize(10).setStatisticsEnabled(true).setBackupCount(2).setAsyncBackupCount(3).setSplitBrainProtectionName("splitBrainProtection").setMergePolicyConfig(mergePolicyConfig).setItemListenerConfigs(singletonList(new ItemListenerConfig("java.Listener", true)));
Config config = new Config().addSetConfig(expectedConfig);
Config decConfig = getNewConfigViaGenerator(config);
SetConfig actualConfig = decConfig.getSetConfig("testSet");
assertEquals(expectedConfig, actualConfig);
}
use of com.hazelcast.config.MergePolicyConfig in project hazelcast by hazelcast.
the class AbstractDynamicConfigGeneratorTest method testMultiMapConfig.
@Test
public void testMultiMapConfig() {
MergePolicyConfig mergePolicyConfig = new MergePolicyConfig().setPolicy(DiscardMergePolicy.class.getSimpleName()).setBatchSize(2342);
MultiMapConfig multiMapConfig = new MultiMapConfig().setName("myMultiMap").setBackupCount(2).setAsyncBackupCount(3).setBinary(false).setMergePolicyConfig(mergePolicyConfig);
Config config = new Config().addMultiMapConfig(multiMapConfig);
Config decConfig = getNewConfigViaGenerator(config);
assertEquals(multiMapConfig, decConfig.getMultiMapConfig("myMultiMap"));
}
use of com.hazelcast.config.MergePolicyConfig in project hazelcast by hazelcast.
the class AbstractDynamicConfigGeneratorTest method testCardinalityEstimator.
// CARDINALITY ESTIMATOR
@Test
public void testCardinalityEstimator() {
Config cfg = new Config();
CardinalityEstimatorConfig estimatorConfig = new CardinalityEstimatorConfig().setBackupCount(2).setAsyncBackupCount(3).setName("Existing").setSplitBrainProtectionName("splitBrainProtection").setMergePolicyConfig(new MergePolicyConfig("DiscardMergePolicy", 14));
cfg.addCardinalityEstimatorConfig(estimatorConfig);
CardinalityEstimatorConfig defaultCardinalityEstConfig = new CardinalityEstimatorConfig();
cfg.addCardinalityEstimatorConfig(defaultCardinalityEstConfig);
CardinalityEstimatorConfig existing = getNewConfigViaGenerator(cfg).getCardinalityEstimatorConfig("Existing");
assertEquals(estimatorConfig, existing);
CardinalityEstimatorConfig fallbacksToDefault = getNewConfigViaGenerator(cfg).getCardinalityEstimatorConfig("NotExisting/Default");
assertEquals(defaultCardinalityEstConfig.getMergePolicyConfig(), fallbacksToDefault.getMergePolicyConfig());
assertEquals(defaultCardinalityEstConfig.getBackupCount(), fallbacksToDefault.getBackupCount());
assertEquals(defaultCardinalityEstConfig.getAsyncBackupCount(), fallbacksToDefault.getAsyncBackupCount());
assertEquals(defaultCardinalityEstConfig.getSplitBrainProtectionName(), fallbacksToDefault.getSplitBrainProtectionName());
}
Aggregations