Search in sources :

Example 51 with MergePolicyConfig

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();
    }
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) MapConfig(com.hazelcast.config.MapConfig) MultiMapConfig(com.hazelcast.config.MultiMapConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig)

Example 52 with MergePolicyConfig

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();
        }
    }
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig)

Example 53 with MergePolicyConfig

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);
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) ListConfig(com.hazelcast.config.ListConfig) EventJournalConfig(com.hazelcast.config.EventJournalConfig) AwsConfig(com.hazelcast.config.AwsConfig) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) MapConfig(com.hazelcast.config.MapConfig) PredicateConfig(com.hazelcast.config.PredicateConfig) MultiMapConfig(com.hazelcast.config.MultiMapConfig) PartitioningStrategyConfig(com.hazelcast.config.PartitioningStrategyConfig) ExecutorConfig(com.hazelcast.config.ExecutorConfig) DiscoveryStrategyConfig(com.hazelcast.config.DiscoveryStrategyConfig) DiskTierConfig(com.hazelcast.config.DiskTierConfig) IndexConfig(com.hazelcast.config.IndexConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) ItemListenerConfig(com.hazelcast.config.ItemListenerConfig) MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) CacheSimpleEntryListenerConfig(com.hazelcast.config.CacheSimpleEntryListenerConfig) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig) WanConsumerConfig(com.hazelcast.config.WanConsumerConfig) AttributeConfig(com.hazelcast.config.AttributeConfig) SetConfig(com.hazelcast.config.SetConfig) PNCounterConfig(com.hazelcast.config.PNCounterConfig) QueueConfig(com.hazelcast.config.QueueConfig) ListenerConfig(com.hazelcast.config.ListenerConfig) CardinalityEstimatorConfig(com.hazelcast.config.CardinalityEstimatorConfig) WanCustomPublisherConfig(com.hazelcast.config.WanCustomPublisherConfig) WanBatchPublisherConfig(com.hazelcast.config.WanBatchPublisherConfig) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) TieredStoreConfig(com.hazelcast.config.TieredStoreConfig) QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) ScheduledExecutorConfig(com.hazelcast.config.ScheduledExecutorConfig) TopicConfig(com.hazelcast.config.TopicConfig) Config(com.hazelcast.config.Config) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) DataPersistenceConfig(com.hazelcast.config.DataPersistenceConfig) DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig) MapPartitionLostListenerConfig(com.hazelcast.config.MapPartitionLostListenerConfig) WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) FlakeIdGeneratorConfig(com.hazelcast.config.FlakeIdGeneratorConfig) MerkleTreeConfig(com.hazelcast.config.MerkleTreeConfig) MemoryTierConfig(com.hazelcast.config.MemoryTierConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) ItemListenerConfig(com.hazelcast.config.ItemListenerConfig) SetConfig(com.hazelcast.config.SetConfig) Test(org.junit.Test)

Example 54 with MergePolicyConfig

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"));
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) ListConfig(com.hazelcast.config.ListConfig) EventJournalConfig(com.hazelcast.config.EventJournalConfig) AwsConfig(com.hazelcast.config.AwsConfig) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) MapConfig(com.hazelcast.config.MapConfig) PredicateConfig(com.hazelcast.config.PredicateConfig) MultiMapConfig(com.hazelcast.config.MultiMapConfig) PartitioningStrategyConfig(com.hazelcast.config.PartitioningStrategyConfig) ExecutorConfig(com.hazelcast.config.ExecutorConfig) DiscoveryStrategyConfig(com.hazelcast.config.DiscoveryStrategyConfig) DiskTierConfig(com.hazelcast.config.DiskTierConfig) IndexConfig(com.hazelcast.config.IndexConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) ItemListenerConfig(com.hazelcast.config.ItemListenerConfig) MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) CacheSimpleEntryListenerConfig(com.hazelcast.config.CacheSimpleEntryListenerConfig) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig) WanConsumerConfig(com.hazelcast.config.WanConsumerConfig) AttributeConfig(com.hazelcast.config.AttributeConfig) SetConfig(com.hazelcast.config.SetConfig) PNCounterConfig(com.hazelcast.config.PNCounterConfig) QueueConfig(com.hazelcast.config.QueueConfig) ListenerConfig(com.hazelcast.config.ListenerConfig) CardinalityEstimatorConfig(com.hazelcast.config.CardinalityEstimatorConfig) WanCustomPublisherConfig(com.hazelcast.config.WanCustomPublisherConfig) WanBatchPublisherConfig(com.hazelcast.config.WanBatchPublisherConfig) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) TieredStoreConfig(com.hazelcast.config.TieredStoreConfig) QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) ScheduledExecutorConfig(com.hazelcast.config.ScheduledExecutorConfig) TopicConfig(com.hazelcast.config.TopicConfig) Config(com.hazelcast.config.Config) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) DataPersistenceConfig(com.hazelcast.config.DataPersistenceConfig) DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig) MapPartitionLostListenerConfig(com.hazelcast.config.MapPartitionLostListenerConfig) WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) FlakeIdGeneratorConfig(com.hazelcast.config.FlakeIdGeneratorConfig) MerkleTreeConfig(com.hazelcast.config.MerkleTreeConfig) MemoryTierConfig(com.hazelcast.config.MemoryTierConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) MultiMapConfig(com.hazelcast.config.MultiMapConfig) Test(org.junit.Test)

Example 55 with MergePolicyConfig

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());
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) ListConfig(com.hazelcast.config.ListConfig) EventJournalConfig(com.hazelcast.config.EventJournalConfig) AwsConfig(com.hazelcast.config.AwsConfig) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) MapConfig(com.hazelcast.config.MapConfig) PredicateConfig(com.hazelcast.config.PredicateConfig) MultiMapConfig(com.hazelcast.config.MultiMapConfig) PartitioningStrategyConfig(com.hazelcast.config.PartitioningStrategyConfig) ExecutorConfig(com.hazelcast.config.ExecutorConfig) DiscoveryStrategyConfig(com.hazelcast.config.DiscoveryStrategyConfig) DiskTierConfig(com.hazelcast.config.DiskTierConfig) IndexConfig(com.hazelcast.config.IndexConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) ItemListenerConfig(com.hazelcast.config.ItemListenerConfig) MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) CacheSimpleEntryListenerConfig(com.hazelcast.config.CacheSimpleEntryListenerConfig) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig) WanConsumerConfig(com.hazelcast.config.WanConsumerConfig) AttributeConfig(com.hazelcast.config.AttributeConfig) SetConfig(com.hazelcast.config.SetConfig) PNCounterConfig(com.hazelcast.config.PNCounterConfig) QueueConfig(com.hazelcast.config.QueueConfig) ListenerConfig(com.hazelcast.config.ListenerConfig) CardinalityEstimatorConfig(com.hazelcast.config.CardinalityEstimatorConfig) WanCustomPublisherConfig(com.hazelcast.config.WanCustomPublisherConfig) WanBatchPublisherConfig(com.hazelcast.config.WanBatchPublisherConfig) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) TieredStoreConfig(com.hazelcast.config.TieredStoreConfig) QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) ScheduledExecutorConfig(com.hazelcast.config.ScheduledExecutorConfig) TopicConfig(com.hazelcast.config.TopicConfig) Config(com.hazelcast.config.Config) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) DataPersistenceConfig(com.hazelcast.config.DataPersistenceConfig) DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig) MapPartitionLostListenerConfig(com.hazelcast.config.MapPartitionLostListenerConfig) WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) FlakeIdGeneratorConfig(com.hazelcast.config.FlakeIdGeneratorConfig) MerkleTreeConfig(com.hazelcast.config.MerkleTreeConfig) MemoryTierConfig(com.hazelcast.config.MemoryTierConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) CardinalityEstimatorConfig(com.hazelcast.config.CardinalityEstimatorConfig) Test(org.junit.Test)

Aggregations

MergePolicyConfig (com.hazelcast.config.MergePolicyConfig)65 Config (com.hazelcast.config.Config)21 Test (org.junit.Test)20 ReplicatedMapConfig (com.hazelcast.config.ReplicatedMapConfig)18 MapConfig (com.hazelcast.config.MapConfig)17 MultiMapConfig (com.hazelcast.config.MultiMapConfig)17 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)16 ItemListenerConfig (com.hazelcast.config.ItemListenerConfig)16 QueueStoreConfig (com.hazelcast.config.QueueStoreConfig)15 RingbufferStoreConfig (com.hazelcast.config.RingbufferStoreConfig)15 ScheduledExecutorConfig (com.hazelcast.config.ScheduledExecutorConfig)15 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)13 EvictionConfig (com.hazelcast.config.EvictionConfig)13 ListenerConfig (com.hazelcast.config.ListenerConfig)13 QueueConfig (com.hazelcast.config.QueueConfig)13 RingbufferConfig (com.hazelcast.config.RingbufferConfig)13 EventJournalConfig (com.hazelcast.config.EventJournalConfig)12 ListConfig (com.hazelcast.config.ListConfig)12 MapPartitionLostListenerConfig (com.hazelcast.config.MapPartitionLostListenerConfig)12 SetConfig (com.hazelcast.config.SetConfig)12