Search in sources :

Example 16 with IgniteBiInClosure

use of org.apache.ignite.lang.IgniteBiInClosure in project ignite by apache.

the class CacheTtlAbstractSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    ccfg.setCacheMode(cacheMode());
    ccfg.setAtomicityMode(atomicityMode());
    LruEvictionPolicy plc = new LruEvictionPolicy();
    plc.setMaxSize(MAX_CACHE_SIZE);
    ccfg.setEvictionPolicy(plc);
    ccfg.setOnheapCacheEnabled(true);
    ccfg.setIndexedTypes(Integer.class, Integer.class);
    ccfg.setBackups(2);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setRebalanceMode(SYNC);
    ccfg.setCacheStoreFactory(singletonFactory(new CacheStoreAdapter() {

        @Override
        public void loadCache(IgniteBiInClosure clo, Object... args) {
            for (int i = 0; i < SIZE; i++) clo.apply(i, i);
        }

        @Override
        public Object load(Object key) throws CacheLoaderException {
            return key;
        }

        @Override
        public void write(Cache.Entry entry) throws CacheWriterException {
        // No-op.
        }

        @Override
        public void delete(Object key) throws CacheWriterException {
        // No-op.
        }
    }));
    ccfg.setExpiryPolicyFactory(FactoryBuilder.factoryOf(new TouchedExpiryPolicy(new Duration(MILLISECONDS, DEFAULT_TIME_TO_LIVE))));
    cfg.setCacheConfiguration(ccfg);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheStoreAdapter(org.apache.ignite.cache.store.CacheStoreAdapter) TouchedExpiryPolicy(javax.cache.expiry.TouchedExpiryPolicy) Duration(javax.cache.expiry.Duration) IgniteBiInClosure(org.apache.ignite.lang.IgniteBiInClosure) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) LruEvictionPolicy(org.apache.ignite.cache.eviction.lru.LruEvictionPolicy) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

IgniteBiInClosure (org.apache.ignite.lang.IgniteBiInClosure)16 IgniteException (org.apache.ignite.IgniteException)5 IgniteLogger (org.apache.ignite.IgniteLogger)5 HashMap (java.util.HashMap)4 UUID (java.util.UUID)4 Ignite (org.apache.ignite.Ignite)4 IgniteCache (org.apache.ignite.IgniteCache)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 MutableEntry (javax.cache.processor.MutableEntry)3 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 File (java.io.File)2 IOException (java.io.IOException)2 Map (java.util.Map)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Cache (javax.cache.Cache)2 CacheEntryEvent (javax.cache.event.CacheEntryEvent)2