Search in sources :

Example 1 with FifoEvictionPolicy

use of org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy in project ignite by apache.

the class EvictionPolicies method FIFO.

public static void FIFO() {
    // tag::FIFO[]
    CacheConfiguration cacheCfg = new CacheConfiguration();
    cacheCfg.setName("cacheName");
    // Enabling on-heap caching for this distributed cache.
    cacheCfg.setOnheapCacheEnabled(true);
    // Set the maximum cache size to 1 million (default is 100,000).
    cacheCfg.setEvictionPolicyFactory(() -> new FifoEvictionPolicy(1000000));
    IgniteConfiguration cfg = new IgniteConfiguration();
    cfg.setCacheConfiguration(cacheCfg);
// end::FIFO[]
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) FifoEvictionPolicy(org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 2 with FifoEvictionPolicy

use of org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy in project ignite by apache.

the class GridCacheObjectToStringSelfTest method testLocalCacheFifoEvictionPolicy.

/**
 * @throws Exception If failed.
 */
@Test
public void testLocalCacheFifoEvictionPolicy() throws Exception {
    cacheMode = LOCAL;
    evictionPlc = new FifoEvictionPolicy();
    checkToString();
}
Also used : FifoEvictionPolicy(org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 3 with FifoEvictionPolicy

use of org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy in project ignite by apache.

the class GridCacheObjectToStringSelfTest method testPartitionedCacheFifoEvictionPolicy.

/**
 * @throws Exception If failed.
 */
@Test
public void testPartitionedCacheFifoEvictionPolicy() throws Exception {
    cacheMode = PARTITIONED;
    nearEnabled = true;
    evictionPlc = new FifoEvictionPolicy();
    checkToString();
}
Also used : FifoEvictionPolicy(org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 4 with FifoEvictionPolicy

use of org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy in project ignite by apache.

the class GridCacheObjectToStringSelfTest method testColocatedCacheFifoEvictionPolicy.

/**
 * @throws Exception If failed.
 */
@Test
public void testColocatedCacheFifoEvictionPolicy() throws Exception {
    cacheMode = PARTITIONED;
    nearEnabled = false;
    evictionPlc = new FifoEvictionPolicy();
    checkToString();
}
Also used : FifoEvictionPolicy(org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 5 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.
 */
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)28 Test (org.junit.Test)14 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)11 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)10 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)10 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)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 AbstractIndexingCommonTest (org.apache.ignite.internal.processors.cache.index.AbstractIndexingCommonTest)2 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)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 QueryEntity (org.apache.ignite.cache.QueryEntity)1