Search in sources :

Example 21 with LruEvictionPolicy

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

Example 22 with LruEvictionPolicy

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

Example 23 with LruEvictionPolicy

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

Aggregations

LruEvictionPolicy (org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)23 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)15 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)11 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)9 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)6 Ignite (org.apache.ignite.Ignite)2 IgniteCache (org.apache.ignite.IgniteCache)2 FifoEvictionPolicy (org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy)2 CacheStoreAdapter (org.apache.ignite.cache.store.CacheStoreAdapter)2 AtomicConfiguration (org.apache.ignite.configuration.AtomicConfiguration)2 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)2 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 Callable (java.util.concurrent.Callable)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 CacheException (javax.cache.CacheException)1 FactoryBuilder (javax.cache.configuration.FactoryBuilder)1 Duration (javax.cache.expiry.Duration)1