use of org.apache.ignite.cache.eviction.lru.LruEvictionPolicy in project ignite by apache.
the class GridCacheConcurrentEvictionsSelfTest method testConcurrentPutsLruLocal.
/**
* @throws Exception If failed.
*/
public void testConcurrentPutsLruLocal() throws Exception {
mode = LOCAL;
LruEvictionPolicy plc = new LruEvictionPolicy();
plc.setMaxSize(1000);
this.plc = plc;
warmUpPutsCnt = 100000;
iterCnt = 100000;
checkConcurrentPuts();
}
use of org.apache.ignite.cache.eviction.lru.LruEvictionPolicy in project ignite by apache.
the class LruNearOnlyNearEvictionPolicySelfTest method checkNearEvictionMaxSize.
/**
* @throws Exception If failed.
*/
private void checkNearEvictionMaxSize() throws Exception {
startGrids(GRID_COUNT);
try {
NearCacheConfiguration nearCfg = new NearCacheConfiguration();
LruEvictionPolicy plc = new LruEvictionPolicy();
plc.setMaxSize(EVICTION_MAX_SIZE);
nearCfg.setNearEvictionPolicy(plc);
grid(0).createNearCache(DEFAULT_CACHE_NAME, nearCfg);
int cnt = 1000;
info("Inserting " + cnt + " keys to cache.");
try (IgniteDataStreamer<Integer, String> ldr = grid(1).dataStreamer(DEFAULT_CACHE_NAME)) {
for (int i = 0; i < cnt; i++) ldr.addData(i, Integer.toString(i));
}
assertTrue("Near cache size " + near(0).nearSize() + ", but eviction maximum size " + EVICTION_MAX_SIZE, near(0).nearSize() <= EVICTION_MAX_SIZE);
info("Getting " + cnt + " keys from cache.");
for (int i = 0; i < cnt; i++) {
IgniteCache<Integer, String> cache = grid(0).cache(DEFAULT_CACHE_NAME);
assertTrue(cache.get(i).equals(Integer.toString(i)));
}
assertTrue("Near cache size " + near(0).nearSize() + ", but eviction maximum size " + EVICTION_MAX_SIZE, near(0).nearSize() <= EVICTION_MAX_SIZE);
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.cache.eviction.lru.LruEvictionPolicy in project ignite by apache.
the class IgniteCacheLoadRebalanceEvictionSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(IP_FINDER);
cfg.setDiscoverySpi(discoSpi);
LruEvictionPolicy evictionPolicy = new LruEvictionPolicy<>();
evictionPolicy.setMaxSize(LRU_MAX_SIZE);
CacheConfiguration<String, byte[]> cacheCfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
cacheCfg.setCacheMode(CacheMode.PARTITIONED);
cacheCfg.setBackups(1);
cacheCfg.setReadFromBackup(true);
cacheCfg.setEvictionPolicy(evictionPolicy);
cacheCfg.setOnheapCacheEnabled(true);
cacheCfg.setStatisticsEnabled(true);
cacheCfg.setWriteThrough(false);
cacheCfg.setReadThrough(false);
cacheCfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(new Storage()));
cfg.setCacheConfiguration(cacheCfg);
return cfg;
}
Aggregations