Search in sources :

Example 31 with MergePolicyConfig

use of com.hazelcast.config.MergePolicyConfig in project hazelcast by hazelcast.

the class DynamicConfigTest method getMapConfig.

private MapConfig getMapConfig() {
    MapConfig mapConfig = new MapConfig(name);
    mapConfig.setAsyncBackupCount(3).setBackupCount(2).setCacheDeserializedValues(CacheDeserializedValues.ALWAYS).setMerkleTreeConfig(new MerkleTreeConfig().setEnabled(true).setDepth(15)).setEventJournalConfig(new EventJournalConfig().setEnabled(true).setCapacity(42).setTimeToLiveSeconds(52)).setHotRestartConfig(new HotRestartConfig().setEnabled(true).setFsync(true)).setInMemoryFormat(InMemoryFormat.OBJECT).setMergePolicyConfig(new MergePolicyConfig(NON_DEFAULT_MERGE_POLICY, NON_DEFAULT_MERGE_BATCH_SIZE)).setTimeToLiveSeconds(220).setMaxIdleSeconds(110).setSplitBrainProtectionName(randomString()).addAttributeConfig(new AttributeConfig("attributeName", "com.attribute.extractor")).addIndexConfig(new IndexConfig(IndexType.SORTED, "attr")).setMetadataPolicy(MetadataPolicy.OFF).setReadBackupData(true).setStatisticsEnabled(false).setPerEntryStatsEnabled(true);
    mapConfig.getEvictionConfig().setEvictionPolicy(EvictionPolicy.RANDOM).setSize(4096).setMaxSizePolicy(MaxSizePolicy.PER_NODE);
    return mapConfig;
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) HotRestartConfig(com.hazelcast.config.HotRestartConfig) IndexConfig(com.hazelcast.config.IndexConfig) MapConfig(com.hazelcast.config.MapConfig) MultiMapConfig(com.hazelcast.config.MultiMapConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) MerkleTreeConfig(com.hazelcast.config.MerkleTreeConfig) AttributeConfig(com.hazelcast.config.AttributeConfig) EventJournalConfig(com.hazelcast.config.EventJournalConfig)

Example 32 with MergePolicyConfig

use of com.hazelcast.config.MergePolicyConfig in project hazelcast by hazelcast.

the class AbstractDynamicConfigGeneratorTest method testQueue.

private void testQueue(QueueStoreConfig queueStoreConfig) {
    MergePolicyConfig mergePolicyConfig = new MergePolicyConfig().setPolicy(DiscardMergePolicy.class.getSimpleName()).setBatchSize(1234);
    QueueConfig expectedConfig = new QueueConfig().setName("testQueue").setPriorityComparatorClassName("com.hazelcast.collection.impl.queue.model.PriorityElementComparator").setMaxSize(10).setStatisticsEnabled(true).setBackupCount(2).setAsyncBackupCount(3).setEmptyQueueTtl(1000).setMergePolicyConfig(mergePolicyConfig).setQueueStoreConfig(queueStoreConfig).setItemListenerConfigs(singletonList(new ItemListenerConfig("java.Listener", true)));
    Config config = new Config().addQueueConfig(expectedConfig);
    Config decConfig = getNewConfigViaGenerator(config);
    QueueConfig actualConfig = decConfig.getQueueConfig("testQueue");
    assertEquals("testQueue", actualConfig.getName());
    MergePolicyConfig decMergePolicyConfig = actualConfig.getMergePolicyConfig();
    assertEquals(DiscardMergePolicy.class.getSimpleName(), decMergePolicyConfig.getPolicy());
    assertEquals(1234, decMergePolicyConfig.getBatchSize());
    ConfigCompatibilityChecker.checkQueueConfig(expectedConfig, actualConfig);
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) QueueConfig(com.hazelcast.config.QueueConfig) 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) DiscardMergePolicy(com.hazelcast.spi.merge.DiscardMergePolicy)

Example 33 with MergePolicyConfig

use of com.hazelcast.config.MergePolicyConfig in project hazelcast by hazelcast.

the class DynamicConfigTest method testScheduledExecutorConfig.

@Test
public void testScheduledExecutorConfig() {
    ScheduledExecutorConfig config = new ScheduledExecutorConfig(name, 2, 3, 10, null, new MergePolicyConfig(NON_DEFAULT_MERGE_POLICY, NON_DEFAULT_MERGE_BATCH_SIZE), ScheduledExecutorConfig.CapacityPolicy.PER_NODE, false);
    driver.getConfig().addScheduledExecutorConfig(config);
    assertConfigurationsEqualOnAllMembers(config);
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) ScheduledExecutorConfig(com.hazelcast.config.ScheduledExecutorConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 34 with MergePolicyConfig

use of com.hazelcast.config.MergePolicyConfig in project hazelcast by hazelcast.

the class DynamicConfigTest method testMultiMapConfig_whenEntryListenerConfigHasImplementation.

@Test
public void testMultiMapConfig_whenEntryListenerConfigHasImplementation() {
    MultiMapConfig multiMapConfig = new MultiMapConfig(name).setBackupCount(4).setAsyncBackupCount(2).setStatisticsEnabled(true).setBinary(true).setValueCollectionType(LIST).setMergePolicyConfig(new MergePolicyConfig(NON_DEFAULT_MERGE_POLICY, NON_DEFAULT_MERGE_BATCH_SIZE)).addEntryListenerConfig(new EntryListenerConfig(new SampleEntryListener(), true, false));
    driver.getConfig().addMultiMapConfig(multiMapConfig);
    assertConfigurationsEqualOnAllMembers(multiMapConfig);
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) MultiMapConfig(com.hazelcast.config.MultiMapConfig) CacheSimpleEntryListenerConfig(com.hazelcast.config.CacheSimpleEntryListenerConfig) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 35 with MergePolicyConfig

use of com.hazelcast.config.MergePolicyConfig in project cas by apereo.

the class HazelcastConfigurationFactory method buildMapConfig.

/**
 * Build map config map config.
 *
 * @param hz             the hz
 * @param mapName        the storage name
 * @param timeoutSeconds the timeoutSeconds
 * @return the map config
 */
public static NamedConfig buildMapConfig(final BaseHazelcastProperties hz, final String mapName, final long timeoutSeconds) {
    val cluster = hz.getCluster();
    val evictionPolicy = EvictionPolicy.valueOf(cluster.getCore().getEvictionPolicy());
    val evictionConfig = new EvictionConfig();
    evictionConfig.setEvictionPolicy(evictionPolicy);
    evictionConfig.setMaxSizePolicy(MaxSizePolicy.valueOf(cluster.getCore().getMaxSizePolicy()));
    evictionConfig.setSize(cluster.getCore().getMaxSize());
    val mergePolicyConfig = new MergePolicyConfig();
    if (StringUtils.hasText(cluster.getCore().getMapMergePolicy())) {
        switch(cluster.getCore().getMapMergePolicy().trim().toLowerCase()) {
            case "discard":
                mergePolicyConfig.setPolicy(DiscardMergePolicy.class.getName());
                break;
            case "pass_through":
                mergePolicyConfig.setPolicy(PassThroughMergePolicy.class.getName());
                break;
            case "expiration_time":
                mergePolicyConfig.setPolicy(ExpirationTimeMergePolicy.class.getName());
                break;
            case "higher_hits":
                mergePolicyConfig.setPolicy(HigherHitsMergePolicy.class.getName());
                break;
            case "latest_update":
                mergePolicyConfig.setPolicy(LatestUpdateMergePolicy.class.getName());
                break;
            case "latest_access":
                mergePolicyConfig.setPolicy(LatestAccessMergePolicy.class.getName());
                break;
            case "put_if_absent":
            default:
                mergePolicyConfig.setPolicy(PutIfAbsentMergePolicy.class.getName());
                break;
        }
    }
    if (cluster.getCore().isReplicated()) {
        return new ReplicatedMapConfig().setName(mapName).setStatisticsEnabled(true).setAsyncFillup(cluster.getCore().isAsyncFillup()).setInMemoryFormat(InMemoryFormat.BINARY).setSplitBrainProtectionName(mapName.concat("-SplitBrainProtection")).setMergePolicyConfig(mergePolicyConfig);
    }
    return new MapConfig().setName(mapName).setStatisticsEnabled(true).setMergePolicyConfig(mergePolicyConfig).setMaxIdleSeconds((int) timeoutSeconds).setBackupCount(cluster.getCore().getBackupCount()).setAsyncBackupCount(cluster.getCore().getAsyncBackupCount()).setEvictionConfig(evictionConfig);
}
Also used : lombok.val(lombok.val) MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) ExpirationTimeMergePolicy(com.hazelcast.spi.merge.ExpirationTimeMergePolicy) LatestAccessMergePolicy(com.hazelcast.spi.merge.LatestAccessMergePolicy) HigherHitsMergePolicy(com.hazelcast.spi.merge.HigherHitsMergePolicy) PassThroughMergePolicy(com.hazelcast.spi.merge.PassThroughMergePolicy) PutIfAbsentMergePolicy(com.hazelcast.spi.merge.PutIfAbsentMergePolicy) EvictionConfig(com.hazelcast.config.EvictionConfig) LatestUpdateMergePolicy(com.hazelcast.spi.merge.LatestUpdateMergePolicy) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) MapConfig(com.hazelcast.config.MapConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) DiscardMergePolicy(com.hazelcast.spi.merge.DiscardMergePolicy)

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