Search in sources :

Example 11 with LruEvictionPolicy

use of org.apache.ignite.cache.eviction.lru.LruEvictionPolicy in project ignite by apache.

the class IgniteNode method start.

/** {@inheritDoc} */
@Override
public void start(BenchmarkConfiguration cfg) throws Exception {
    IgniteBenchmarkArguments args = new IgniteBenchmarkArguments();
    BenchmarkUtils.jcommander(cfg.commandLineArguments(), args, "<ignite-node>");
    IgniteBiTuple<IgniteConfiguration, ? extends ApplicationContext> tup = loadConfiguration(args.configuration());
    IgniteConfiguration c = tup.get1();
    assert c != null;
    if (args.cleanWorkDirectory())
        FileUtils.cleanDirectory(U.workDirectory(c.getWorkDirectory(), c.getIgniteHome()));
    ApplicationContext appCtx = tup.get2();
    assert appCtx != null;
    CacheConfiguration[] ccfgs = c.getCacheConfiguration();
    if (ccfgs != null) {
        for (CacheConfiguration cc : ccfgs) {
            // IgniteNode can not run in CLIENT_ONLY mode,
            // except the case when it's used inside IgniteAbstractBenchmark.
            boolean cl = args.isClientOnly() && (args.isNearCache() || clientMode);
            if (cl)
                c.setClientMode(true);
            if (args.isNearCache()) {
                NearCacheConfiguration nearCfg = new NearCacheConfiguration();
                if (args.getNearCacheSize() != 0)
                    nearCfg.setNearEvictionPolicy(new LruEvictionPolicy(args.getNearCacheSize()));
                cc.setNearConfiguration(nearCfg);
            }
            cc.setWriteSynchronizationMode(args.syncMode());
            cc.setBackups(args.backups());
            if (args.restTcpPort() != 0) {
                ConnectorConfiguration ccc = new ConnectorConfiguration();
                ccc.setPort(args.restTcpPort());
                if (args.restTcpHost() != null)
                    ccc.setHost(args.restTcpHost());
                c.setConnectorConfiguration(ccc);
            }
            cc.setReadThrough(args.isStoreEnabled());
            cc.setWriteThrough(args.isStoreEnabled());
            cc.setWriteBehindEnabled(args.isWriteBehind());
            BenchmarkUtils.println(cfg, "Cache configured with the following parameters: " + cc);
        }
    } else
        BenchmarkUtils.println(cfg, "There are no caches configured");
    TransactionConfiguration tc = c.getTransactionConfiguration();
    tc.setDefaultTxConcurrency(args.txConcurrency());
    tc.setDefaultTxIsolation(args.txIsolation());
    TcpCommunicationSpi commSpi = (TcpCommunicationSpi) c.getCommunicationSpi();
    if (commSpi == null)
        commSpi = new TcpCommunicationSpi();
    c.setCommunicationSpi(commSpi);
    if (args.getPageSize() != MemoryConfiguration.DFLT_PAGE_SIZE) {
        MemoryConfiguration dbCfg = c.getMemoryConfiguration();
        if (dbCfg == null) {
            dbCfg = new MemoryConfiguration();
            c.setMemoryConfiguration(dbCfg);
        }
        dbCfg.setPageSize(args.getPageSize());
    }
    ignite = IgniteSpring.start(c, appCtx);
    BenchmarkUtils.println("Configured marshaller: " + ignite.cluster().localNode().attribute(ATTR_MARSHALLER));
}
Also used : TransactionConfiguration(org.apache.ignite.configuration.TransactionConfiguration) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) ConnectorConfiguration(org.apache.ignite.configuration.ConnectorConfiguration) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) ApplicationContext(org.springframework.context.ApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) LruEvictionPolicy(org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)

Example 12 with LruEvictionPolicy

use of org.apache.ignite.cache.eviction.lru.LruEvictionPolicy in project ignite by apache.

the class GridCachePartitionedAtomicLongLoadTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
    AtomicConfiguration atomicCfg = new AtomicConfiguration();
    atomicCfg.setCacheMode(PARTITIONED);
    atomicCfg.setBackups(1);
    atomicCfg.setAtomicSequenceReserveSize(10);
    c.setAtomicConfiguration(atomicCfg);
    c.getTransactionConfiguration().setDefaultTxConcurrency(PESSIMISTIC);
    c.getTransactionConfiguration().setDefaultTxIsolation(REPEATABLE_READ);
    CacheConfiguration cc = defaultCacheConfiguration();
    cc.setCacheMode(CacheMode.PARTITIONED);
    cc.setRebalanceMode(CacheRebalanceMode.SYNC);
    cc.setWriteSynchronizationMode(FULL_SYNC);
    LruEvictionPolicy plc = new LruEvictionPolicy();
    plc.setMaxSize(1000);
    cc.setEvictionPolicy(plc);
    cc.setOnheapCacheEnabled(true);
    cc.setBackups(1);
    cc.setAffinity(new RendezvousAffinityFunction(true));
    c.setCacheConfiguration(cc);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(ipFinder);
    c.setDiscoverySpi(disco);
    return c;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) LruEvictionPolicy(org.apache.ignite.cache.eviction.lru.LruEvictionPolicy) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 13 with LruEvictionPolicy

use of org.apache.ignite.cache.eviction.lru.LruEvictionPolicy in project ignite by apache.

the class CacheQueryEvictDataLostTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration() throws Exception {
    IgniteConfiguration cfg = super.getConfiguration();
    CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
    ccfg.setName("cache-1");
    ccfg.setEvictionPolicy(new LruEvictionPolicy(10));
    ccfg.setOnheapCacheEnabled(true);
    ccfg.setIndexedTypes(Integer.class, TestData.class);
    cfg.setCacheConfiguration(ccfg);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) LruEvictionPolicy(org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)

Example 14 with LruEvictionPolicy

use of org.apache.ignite.cache.eviction.lru.LruEvictionPolicy in project ignite by apache.

the class GridCacheMultiNodeLoadTest method getConfiguration.

/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi spi = new TcpDiscoverySpi();
    spi.setIpFinder(ipFinder);
    cfg.setDiscoverySpi(spi);
    CacheConfiguration cacheCfg = defaultCacheConfiguration();
    cacheCfg.setName(CACHE_NAME);
    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setNearConfiguration(null);
    cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    LruEvictionPolicy plc = new LruEvictionPolicy();
    plc.setMaxSize(100000);
    cacheCfg.setEvictionPolicy(plc);
    cacheCfg.setOnheapCacheEnabled(true);
    cacheCfg.setBackups(1);
    cacheCfg.setRebalanceMode(SYNC);
    cfg.setCacheConfiguration(cacheCfg);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) LruEvictionPolicy(org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)

Example 15 with LruEvictionPolicy

use of org.apache.ignite.cache.eviction.lru.LruEvictionPolicy 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

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