本文整理汇总了Java中org.apache.ignite.cache.eviction.lru.LruEvictionPolicy.setMaxSize方法的典型用法代码示例。如果您正苦于以下问题:Java LruEvictionPolicy.setMaxSize方法的具体用法?Java LruEvictionPolicy.setMaxSize怎么用?Java LruEvictionPolicy.setMaxSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.cache.eviction.lru.LruEvictionPolicy
的用法示例。
在下文中一共展示了LruEvictionPolicy.setMaxSize方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConfiguration
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入方法依赖的package包/类
/** {@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;
}
示例2: createPolicy
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected LruEvictionPolicy<String, String> createPolicy(int plcMax) {
LruEvictionPolicy<String, String> plc = new LruEvictionPolicy<>();
plc.setMaxSize(this.plcMax);
plc.setBatchSize(this.plcBatchSize);
plc.setMaxMemorySize(this.plcMaxMemSize);
return plc;
}
示例3: createNearPolicy
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected LruEvictionPolicy<String, String> createNearPolicy(int nearMax) {
LruEvictionPolicy<String, String> plc = new LruEvictionPolicy<>();
plc.setMaxSize(nearMax);
plc.setBatchSize(plcBatchSize);
return plc;
}
示例4: testConcurrentPutsLruLocal
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入方法依赖的package包/类
/**
* @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();
}
示例5: testPolicyConsistencyLruLocalTwoKeys
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入方法依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testPolicyConsistencyLruLocalTwoKeys() throws Exception {
LruEvictionPolicy<Object, Object> plc = new LruEvictionPolicy<>();
plc.setMaxSize(1);
this.plc = plc;
keyCnt = 2;
threadCnt = Runtime.getRuntime().availableProcessors() / 2;
checkPolicyConsistency();
}
示例6: testPolicyConsistencyLruLocalFewKeys
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入方法依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testPolicyConsistencyLruLocalFewKeys() throws Exception {
LruEvictionPolicy<Object, Object> plc = new LruEvictionPolicy<>();
plc.setMaxSize(POLICY_QUEUE_SIZE);
this.plc = plc;
keyCnt = POLICY_QUEUE_SIZE + 5;
checkPolicyConsistency();
}
示例7: testPolicyConsistencyLruLocal
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入方法依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testPolicyConsistencyLruLocal() throws Exception {
LruEvictionPolicy<Object, Object> plc = new LruEvictionPolicy<>();
plc.setMaxSize(POLICY_QUEUE_SIZE);
this.plc = plc;
keyCnt = POLICY_QUEUE_SIZE * 10;
checkPolicyConsistency();
}
示例8: cacheConfiguration
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入方法依赖的package包/类
/**
* @param evict If {@code true} adds eviction policy.
* @param store If {@code true} adds cache store.
* @return Cache configuration.
* @throws Exception If failed.
*/
@SuppressWarnings("unchecked")
protected CacheConfiguration cacheConfiguration(boolean evict, boolean store) throws Exception {
CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
cfg.setAtomicityMode(atomicityMode());
cfg.setWriteSynchronizationMode(FULL_SYNC);
cfg.setBackups(1);
cfg.setRebalanceMode(SYNC);
if (evict) {
LruEvictionPolicy plc = new LruEvictionPolicy();
plc.setMaxSize(100);
cfg.setEvictionPolicy(plc);
cfg.setOnheapCacheEnabled(true);
}
if (store) {
cfg.setCacheStoreFactory(new TestStoreFactory());
cfg.setWriteThrough(true);
}
return cfg;
}
示例9: checkNearEvictionMaxSize
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入方法依赖的package包/类
/**
* @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();
}
}
示例10: getConfiguration
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入方法依赖的package包/类
/** {@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;
}
示例11: getConfiguration
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入方法依赖的package包/类
/** {@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;
}
示例12: getConfiguration
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
CacheConfiguration cc = new CacheConfiguration(DEFAULT_CACHE_NAME);
cc.setCacheMode(PARTITIONED);
cc.setAtomicityMode(atomicityMode);
cc.setWriteSynchronizationMode(PRIMARY_SYNC);
cc.setRebalanceMode(SYNC);
cc.setBackups(0);
NearCacheConfiguration nearCfg = new NearCacheConfiguration();
LruEvictionPolicy plc = new LruEvictionPolicy();
plc.setMaxSize(EVICTION_MAX_SIZE);
nearCfg.setNearEvictionPolicy(plc);
cc.setNearConfiguration(nearCfg);
c.setCacheConfiguration(cc);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
c.setDiscoverySpi(disco);
return c;
}
示例13: getConfiguration
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
c.setDiscoverySpi(disco);
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setName(CACHE_NAME);
ccfg.setAtomicityMode(TRANSACTIONAL);
ccfg.setWriteSynchronizationMode(PRIMARY_SYNC);
ccfg.setBackups(2);
ccfg.setCacheMode(PARTITIONED);
LruEvictionPolicy plc = new LruEvictionPolicy();
plc.setMaxSize(100000);
ccfg.setEvictionPolicy(plc);
ccfg.setOnheapCacheEnabled(true);
c.setCacheConfiguration(ccfg);
c.setClientMode(client);
return c;
}
示例14: getConfiguration
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
c.getTransactionConfiguration().setDefaultTxConcurrency(PESSIMISTIC);
c.getTransactionConfiguration().setDefaultTxIsolation(REPEATABLE_READ);
AtomicConfiguration atomicCfg = new AtomicConfiguration();
atomicCfg.setAtomicSequenceReserveSize(100000);
atomicCfg.setCacheMode(mode);
c.setAtomicConfiguration(atomicCfg);
if (cacheOn) {
CacheConfiguration cc = defaultCacheConfiguration();
cc.setCacheMode(mode);
LruEvictionPolicy plc = new LruEvictionPolicy();
plc.setMaxSize(1000);
cc.setEvictionPolicy(plc);
cc.setOnheapCacheEnabled(true);
cc.setWriteSynchronizationMode(FULL_SYNC);
cc.setRebalanceMode(NONE);
c.setCacheConfiguration(cc);
}
else
c.setCacheConfiguration();
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
c.setDiscoverySpi(disco);
c.setPeerClassLoadingEnabled(false);
return c;
}