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));
}
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;
}
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;
}
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;
}
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;
}
Aggregations