Search in sources :

Example 6 with EvictionConfig

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

the class AbstractNearCachePreloaderTest method getNearCacheConfig.

protected NearCacheConfig getNearCacheConfig(boolean invalidationOnChange, int maxSize, String preloaderDir) {
    EvictionConfig evictionConfig = new EvictionConfig().setMaximumSizePolicy(MaxSizePolicy.ENTRY_COUNT).setSize(maxSize).setEvictionPolicy(EvictionPolicy.LRU);
    NearCacheConfig nearCacheConfig = createNearCacheConfig(InMemoryFormat.BINARY).setName(defaultNearCache).setInvalidateOnChange(invalidationOnChange).setEvictionConfig(evictionConfig);
    nearCacheConfig.getPreloaderConfig().setEnabled(true).setDirectory(preloaderDir);
    return nearCacheConfig;
}
Also used : EvictionConfig(com.hazelcast.config.EvictionConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) NearCacheTestUtils.createNearCacheConfig(com.hazelcast.internal.nearcache.NearCacheTestUtils.createNearCacheConfig)

Example 7 with EvictionConfig

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

the class NearCacheRecordStoreTestSupport method createNearCacheWithMaxSizePolicy.

protected void createNearCacheWithMaxSizePolicy(InMemoryFormat inMemoryFormat, EvictionConfig.MaxSizePolicy maxSizePolicy, int size) {
    NearCacheConfig nearCacheConfig = createNearCacheConfig(DEFAULT_NEAR_CACHE_NAME, inMemoryFormat);
    EvictionConfig evictionConfig = new EvictionConfig();
    evictionConfig.setMaximumSizePolicy(maxSizePolicy);
    evictionConfig.setSize(size);
    nearCacheConfig.setEvictionConfig(evictionConfig);
    createNearCacheRecordStore(nearCacheConfig, inMemoryFormat);
}
Also used : EvictionConfig(com.hazelcast.config.EvictionConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Example 8 with EvictionConfig

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

the class NearCacheRecordStoreTest method doEvictionWithEntryCountMaxSizePolicy.

private void doEvictionWithEntryCountMaxSizePolicy(InMemoryFormat inMemoryFormat, EvictionPolicy evictionPolicy) {
    int maxSize = DEFAULT_RECORD_COUNT / 2;
    NearCacheConfig nearCacheConfig = createNearCacheConfig(DEFAULT_NEAR_CACHE_NAME, inMemoryFormat);
    if (evictionPolicy == null) {
        evictionPolicy = EvictionConfig.DEFAULT_EVICTION_POLICY;
    }
    EvictionConfig evictionConfig = new EvictionConfig();
    evictionConfig.setMaximumSizePolicy(MaxSizePolicy.ENTRY_COUNT);
    evictionConfig.setSize(maxSize);
    evictionConfig.setEvictionPolicy(evictionPolicy);
    nearCacheConfig.setEvictionConfig(evictionConfig);
    NearCacheRecordStore<Integer, String> nearCacheRecordStore = createNearCacheRecordStore(nearCacheConfig, inMemoryFormat);
    for (int i = 0; i < DEFAULT_RECORD_COUNT; i++) {
        nearCacheRecordStore.put(i, "Record-" + i);
        nearCacheRecordStore.doEvictionIfRequired();
        assertTrue(maxSize >= nearCacheRecordStore.size());
    }
}
Also used : EvictionConfig(com.hazelcast.config.EvictionConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Example 9 with EvictionConfig

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

the class QueryCacheSimpleStressTest method setUp.

@Before
public void setUp() {
    EvictionConfig evictionConfig = new EvictionConfig();
    evictionConfig.setMaximumSizePolicy(EvictionConfig.MaxSizePolicy.ENTRY_COUNT);
    evictionConfig.setSize(Integer.MAX_VALUE);
    evictionConfig.setEvictionPolicy(EvictionPolicy.LRU);
    QueryCacheConfig queryCacheConfig = new QueryCacheConfig(cacheName);
    queryCacheConfig.setBufferSize(30).setDelaySeconds(2).setBatchSize(2).setPopulate(true).getPredicateConfig().setImplementation(TruePredicate.INSTANCE);
    queryCacheConfig.setEvictionConfig(evictionConfig);
    MapConfig mapConfig = new MapConfig(mapName);
    mapConfig.addQueryCacheConfig(queryCacheConfig);
    config.addMapConfig(mapConfig);
}
Also used : QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) MapConfig(com.hazelcast.config.MapConfig) Before(org.junit.Before)

Example 10 with EvictionConfig

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

the class CacheEvictionPolicyComparatorTest method test_evictionPolicyComparator_with_comparatorClassName_when_maxSizePolicy_is_entryCount.

@Test
public void test_evictionPolicyComparator_with_comparatorClassName_when_maxSizePolicy_is_entryCount() {
    int partitionCount = Integer.parseInt(GroupProperty.PARTITION_COUNT.getDefaultValue());
    int iterationCount = (EntryCountCacheEvictionChecker.calculateMaxPartitionSize(EvictionConfig.DEFAULT_MAX_ENTRY_COUNT, partitionCount) * partitionCount) * 2;
    EvictionConfig evictionConfig = new EvictionConfig().setComparatorClassName(MyEvictionPolicyComparator.class.getName());
    do_test_evictionPolicyComparator(evictionConfig, iterationCount);
}
Also used : EvictionConfig(com.hazelcast.config.EvictionConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

EvictionConfig (com.hazelcast.config.EvictionConfig)13 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Test (org.junit.Test)5 NearCacheConfig (com.hazelcast.config.NearCacheConfig)4 ParallelTest (com.hazelcast.test.annotation.ParallelTest)3 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)2 Node (org.w3c.dom.Node)2 ClientConfig (com.hazelcast.client.config.ClientConfig)1 MapConfig (com.hazelcast.config.MapConfig)1 QueryCacheConfig (com.hazelcast.config.QueryCacheConfig)1 DistributedObject (com.hazelcast.core.DistributedObject)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 LifecycleEvent (com.hazelcast.core.LifecycleEvent)1 LifecycleListener (com.hazelcast.core.LifecycleListener)1 ConfigValidator.checkEvictionConfig (com.hazelcast.internal.config.ConfigValidator.checkEvictionConfig)1 EvictableEntryView (com.hazelcast.internal.eviction.EvictableEntryView)1 EvictionPolicyComparator (com.hazelcast.internal.eviction.EvictionPolicyComparator)1 NearCacheTestUtils.createNearCacheConfig (com.hazelcast.internal.nearcache.NearCacheTestUtils.createNearCacheConfig)1 NightlyTest (com.hazelcast.test.annotation.NightlyTest)1 CountDownLatch (java.util.concurrent.CountDownLatch)1