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