use of org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy in project ignite by apache.
the class GridCacheEvictionTouchSelfTest method testReload.
/**
* @throws Exception If failed.
*/
public void testReload() throws Exception {
FifoEvictionPolicy<Object, Object> plc = new FifoEvictionPolicy<>();
plc.setMaxSize(100);
this.plc = plc;
try {
Ignite ignite = startGrid(1);
final IgniteCache<Integer, Integer> cache = ignite.cache(DEFAULT_CACHE_NAME);
for (int i = 0; i < 10000; i++) load(cache, i, true);
assertEquals(100, cache.size(CachePeekMode.ONHEAP));
assertEquals(100, ((FifoEvictionPolicy) plc).queue().size());
Set<Integer> keys = new TreeSet<>();
for (int i = 0; i < 10000; i++) keys.add(i);
loadAll(cache, keys, true);
assertEquals(100, cache.size(CachePeekMode.ONHEAP));
assertEquals(100, ((FifoEvictionPolicy) plc).queue().size());
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy in project ignite by apache.
the class GridCacheTtlManagerEvictionSelfTest 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);
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setCacheMode(cacheMode);
ccfg.setEagerTtl(true);
ccfg.setEvictionPolicy(new FifoEvictionPolicy(ENTRIES_LIMIT, 100));
ccfg.setOnheapCacheEnabled(true);
ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.HOURS, 12)));
cfg.setCacheConfiguration(ccfg);
return cfg;
}
use of org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy in project ignite by apache.
the class GridCacheDhtEvictionNearReadersSelfTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
cfg.setDiscoverySpi(disco);
CacheConfiguration cacheCfg = defaultCacheConfiguration();
cacheCfg.setCacheMode(PARTITIONED);
cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cacheCfg.setRebalanceMode(SYNC);
cacheCfg.setAtomicityMode(atomicityMode());
cacheCfg.setBackups(1);
FifoEvictionPolicy plc = new FifoEvictionPolicy();
plc.setMaxSize(10);
cacheCfg.setEvictionPolicy(plc);
cacheCfg.setOnheapCacheEnabled(true);
NearCacheConfiguration nearCfg = new NearCacheConfiguration();
FifoEvictionPolicy nearPlc = new FifoEvictionPolicy();
nearPlc.setMaxSize(10);
nearCfg.setNearEvictionPolicy(nearPlc);
cacheCfg.setNearConfiguration(nearCfg);
cfg.setCacheConfiguration(cacheCfg);
return cfg;
}
use of org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy in project ignite by apache.
the class GridCacheConcurrentEvictionsSelfTest method testConcurrentPutsFifoLocal.
/**
* @throws Exception If failed.
*/
public void testConcurrentPutsFifoLocal() throws Exception {
mode = LOCAL;
FifoEvictionPolicy plc = new FifoEvictionPolicy();
plc.setMaxSize(1000);
this.plc = plc;
warmUpPutsCnt = 100000;
iterCnt = 100000;
checkConcurrentPuts();
}
use of org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy in project ignite by apache.
the class PlatformConfigurationUtils method writeEvictionPolicy.
/**
* Writes the eviction policy.
* @param out Stream.
* @param p Policy.
*/
@SuppressWarnings("TypeMayBeWeakened")
private static void writeEvictionPolicy(BinaryRawWriter out, EvictionPolicy p) {
if (p instanceof FifoEvictionPolicy) {
out.writeByte((byte) 1);
FifoEvictionPolicy p0 = (FifoEvictionPolicy) p;
out.writeInt(p0.getBatchSize());
out.writeInt(p0.getMaxSize());
out.writeLong(p0.getMaxMemorySize());
} else if (p instanceof LruEvictionPolicy) {
out.writeByte((byte) 2);
LruEvictionPolicy p0 = (LruEvictionPolicy) p;
out.writeInt(p0.getBatchSize());
out.writeInt(p0.getMaxSize());
out.writeLong(p0.getMaxMemorySize());
} else
out.writeByte((byte) 0);
}
Aggregations