Search in sources :

Example 6 with FifoEvictionPolicy

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();
    }
}
Also used : TreeSet(java.util.TreeSet) Ignite(org.apache.ignite.Ignite) FifoEvictionPolicy(org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy)

Example 7 with FifoEvictionPolicy

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Duration(javax.cache.expiry.Duration) FifoEvictionPolicy(org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 8 with FifoEvictionPolicy

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) FifoEvictionPolicy(org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 9 with FifoEvictionPolicy

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();
}
Also used : FifoEvictionPolicy(org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy)

Example 10 with FifoEvictionPolicy

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);
}
Also used : FifoEvictionPolicy(org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy) LruEvictionPolicy(org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)

Aggregations

FifoEvictionPolicy (org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy)26 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)8 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)8 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)7 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)7 Ignite (org.apache.ignite.Ignite)5 List (java.util.List)2 LruEvictionPolicy (org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)2 SqlFieldsQuery (org.apache.ignite.cache.query.SqlFieldsQuery)2 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 TreeSet (java.util.TreeSet)1 Cache (javax.cache.Cache)1 Factory (javax.cache.configuration.Factory)1 Duration (javax.cache.expiry.Duration)1 IgniteCache (org.apache.ignite.IgniteCache)1 FifoEvictionPolicyFactory (org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicyFactory)1 GridCacheAlwaysEvictionPolicy (org.apache.ignite.internal.processors.cache.GridCacheAlwaysEvictionPolicy)1 PA (org.apache.ignite.internal.util.typedef.PA)1 Transaction (org.apache.ignite.transactions.Transaction)1