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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations