Search in sources :

Example 6 with HotRestartConfig

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

the class DynamicConfigBouncingTest method createMapConfig.

private static MapConfig createMapConfig(String mapName) {
    NearCacheConfig nearCacheConfig = new NearCacheConfig().setCacheLocalEntries(true).setInMemoryFormat(InMemoryFormat.NATIVE).setLocalUpdatePolicy(NearCacheConfig.LocalUpdatePolicy.CACHE_ON_UPDATE).setPreloaderConfig(new NearCachePreloaderConfig().setEnabled(true));
    HotRestartConfig hotRestartConfig = new HotRestartConfig().setEnabled(true).setFsync(true);
    EvictionConfig evictionConfig = new EvictionConfig();
    evictionConfig.setSize(1000).setMaxSizePolicy(MaxSizePolicy.FREE_HEAP_SIZE).setComparator(new LRUEvictionPolicyComparator());
    MapStoreConfig mapStoreConfig = new MapStoreConfig().setEnabled(true).setClassName("foo.bar.MapStoreDoesNotExist");
    WanReplicationRef wanRef = new WanReplicationRef("name", "foo.bar.PolicyClass", Collections.<String>emptyList(), true);
    EntryListenerConfig classEntryListener = new EntryListenerConfig("foo.bar.ClassName", true, true);
    EntryListenerConfig entryListener = new EntryListenerConfig(new MyEntryListener(), true, true);
    EntryListenerConfig mapListener = new EntryListenerConfig(new MyEntryUpdatedListener(), true, true);
    QueryCacheConfig queryCacheConfig = new QueryCacheConfig("queryCacheName").setBatchSize(100).addIndexConfig(new IndexConfig(IndexType.HASH, "attribute")).addEntryListenerConfig(new EntryListenerConfig("foo.bar.Classname", false, true)).setInMemoryFormat(InMemoryFormat.OBJECT);
    return new MapConfig(mapName).setBackupCount(2).setBackupCount(3).setTimeToLiveSeconds(12).setMaxIdleSeconds(20).setNearCacheConfig(nearCacheConfig).setReadBackupData(true).setCacheDeserializedValues(CacheDeserializedValues.ALWAYS).setInMemoryFormat(InMemoryFormat.OBJECT).setHotRestartConfig(hotRestartConfig).setEvictionConfig(evictionConfig).setMapStoreConfig(mapStoreConfig).setWanReplicationRef(wanRef).addEntryListenerConfig(classEntryListener).addEntryListenerConfig(entryListener).addEntryListenerConfig(mapListener).addMapPartitionLostListenerConfig(new MapPartitionLostListenerConfig("foo.bar.Classname")).addIndexConfig(new IndexConfig(IndexType.SORTED, "orderAttribute")).addIndexConfig(new IndexConfig(IndexType.HASH, "unorderedAttribute")).addAttributeConfig(new AttributeConfig("attribute", "foo.bar.ExtractorClass")).addQueryCacheConfig(queryCacheConfig).setStatisticsEnabled(false).setPerEntryStatsEnabled(true).setPartitioningStrategyConfig(new PartitioningStrategyConfig("foo.bar.Class")).setSplitBrainProtectionName("split-brain-protection");
}
Also used : HotRestartConfig(com.hazelcast.config.HotRestartConfig) QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) MapPartitionLostListenerConfig(com.hazelcast.config.MapPartitionLostListenerConfig) WanReplicationRef(com.hazelcast.config.WanReplicationRef) EvictionConfig(com.hazelcast.config.EvictionConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) PartitioningStrategyConfig(com.hazelcast.config.PartitioningStrategyConfig) IndexConfig(com.hazelcast.config.IndexConfig) NearCachePreloaderConfig(com.hazelcast.config.NearCachePreloaderConfig) LRUEvictionPolicyComparator(com.hazelcast.internal.eviction.impl.comparator.LRUEvictionPolicyComparator) MapConfig(com.hazelcast.config.MapConfig) AttributeConfig(com.hazelcast.config.AttributeConfig)

Example 7 with HotRestartConfig

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

the class CacheConfigHelper method newCompleteCacheConfig.

public static CacheConfig newCompleteCacheConfig(String name) {
    CacheConfig cacheConfig = new CacheConfig();
    cacheConfig.setName(name);
    cacheConfig.setSplitBrainProtectionName("split-brain-protection");
    cacheConfig.setInMemoryFormat(InMemoryFormat.OBJECT);
    cacheConfig.setBackupCount(3);
    cacheConfig.setAsyncBackupCount(2);
    cacheConfig.setWanReplicationRef(new WanReplicationRef(randomName(), "com.hazelcast.MergePolicy", Collections.singletonList("filter"), true));
    cacheConfig.addCacheEntryListenerConfiguration(new MutableCacheEntryListenerConfiguration(new CacheConfigTest.EntryListenerFactory(), null, false, true));
    cacheConfig.getMergePolicyConfig().setPolicy("mergePolicy");
    cacheConfig.setStatisticsEnabled(true);
    cacheConfig.setManagementEnabled(true);
    cacheConfig.setDisablePerEntryInvalidationEvents(true);
    cacheConfig.setKeyClassName("java.lang.Integer");
    cacheConfig.setValueClassName("java.lang.String");
    cacheConfig.setReadThrough(true);
    cacheConfig.setWriteThrough(true);
    cacheConfig.setHotRestartConfig(new HotRestartConfig().setEnabled(true).setFsync(true));
    return cacheConfig;
}
Also used : HotRestartConfig(com.hazelcast.config.HotRestartConfig) WanReplicationRef(com.hazelcast.config.WanReplicationRef) MutableCacheEntryListenerConfiguration(javax.cache.configuration.MutableCacheEntryListenerConfiguration) CacheConfig(com.hazelcast.config.CacheConfig)

Aggregations

HotRestartConfig (com.hazelcast.config.HotRestartConfig)7 WanReplicationRef (com.hazelcast.config.WanReplicationRef)4 AttributeConfig (com.hazelcast.config.AttributeConfig)3 EventJournalConfig (com.hazelcast.config.EventJournalConfig)3 IndexConfig (com.hazelcast.config.IndexConfig)3 MapConfig (com.hazelcast.config.MapConfig)3 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)2 CacheSimpleEntryListenerConfig (com.hazelcast.config.CacheSimpleEntryListenerConfig)2 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)2 EvictionConfig (com.hazelcast.config.EvictionConfig)2 MapPartitionLostListenerConfig (com.hazelcast.config.MapPartitionLostListenerConfig)2 MapStoreConfig (com.hazelcast.config.MapStoreConfig)2 MergePolicyConfig (com.hazelcast.config.MergePolicyConfig)2 MerkleTreeConfig (com.hazelcast.config.MerkleTreeConfig)2 MultiMapConfig (com.hazelcast.config.MultiMapConfig)2 NearCacheConfig (com.hazelcast.config.NearCacheConfig)2 NearCachePreloaderConfig (com.hazelcast.config.NearCachePreloaderConfig)2 PartitioningStrategyConfig (com.hazelcast.config.PartitioningStrategyConfig)2 QueryCacheConfig (com.hazelcast.config.QueryCacheConfig)2 AwsConfig (com.hazelcast.config.AwsConfig)1