本文整理汇总了Java中org.apache.ignite.configuration.CacheConfiguration.setEvictionPolicy方法的典型用法代码示例。如果您正苦于以下问题:Java CacheConfiguration.setEvictionPolicy方法的具体用法?Java CacheConfiguration.setEvictionPolicy怎么用?Java CacheConfiguration.setEvictionPolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.configuration.CacheConfiguration
的用法示例。
在下文中一共展示了CacheConfiguration.setEvictionPolicy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newCache
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Create new ML cache if needed.
*/
private IgniteCache<MatrixBlockKey, MatrixBlockEntry> newCache() {
CacheConfiguration<MatrixBlockKey, MatrixBlockEntry> cfg = new CacheConfiguration<>();
// Write to primary.
cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
// Atomic transactions only.
cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
// No eviction.
cfg.setEvictionPolicy(null);
// No copying of values.
cfg.setCopyOnRead(false);
// Cache is partitioned.
cfg.setCacheMode(CacheMode.PARTITIONED);
// Random cache name.
cfg.setName(CACHE_NAME);
return Ignition.localIgnite().getOrCreateCache(cfg);
}
示例2: newCache
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Create new ML cache if needed.
*/
private IgniteCache<VectorBlockKey, VectorBlockEntry> newCache() {
CacheConfiguration<VectorBlockKey, VectorBlockEntry> cfg = new CacheConfiguration<>();
// Write to primary.
cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
// Atomic transactions only.
cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
// No eviction.
cfg.setEvictionPolicy(null);
// No copying of values.
cfg.setCopyOnRead(false);
// Cache is partitioned.
cfg.setCacheMode(CacheMode.PARTITIONED);
// Random cache name.
cfg.setName(CACHE_NAME);
return Ignition.localIgnite().getOrCreateCache(cfg);
}
示例3: newCache
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Create new ML cache if needed.
*/
private IgniteCache<RowColMatrixKey, Double> newCache() {
CacheConfiguration<RowColMatrixKey, Double> cfg = new CacheConfiguration<>();
// Write to primary.
cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
// Atomic transactions only.
cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
// No eviction.
cfg.setEvictionPolicy(null);
// No copying of values.
cfg.setCopyOnRead(false);
// Cache is partitioned.
cfg.setCacheMode(CacheMode.PARTITIONED);
// Random cache name.
cfg.setName(CACHE_NAME);
return Ignition.localIgnite().getOrCreateCache(cfg);
}
示例4: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName);
ccfg.setBackups(1);
if (hasNearCache())
ccfg.setNearConfiguration(new NearCacheConfiguration());
FifoEvictionPolicy plc = new FifoEvictionPolicy();
plc.setMaxSize(HEAP_ENTRIES);
ccfg.setEvictionPolicy(plc);
ccfg.setOnheapCacheEnabled(true);
return ccfg;
}
示例5: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @param cacheMode Cache mode.
* @param atomicityMode Cache atomicity mode.
* @param evictionPlc Eviction policy.
* @param indexing Indexing flag.
* @return Cache configuration.
*/
private CacheConfiguration<Object, Object> cacheConfiguration(
CacheMode cacheMode,
CacheAtomicityMode atomicityMode,
@Nullable EvictionPolicy<Object, Object> evictionPlc,
boolean indexing) {
CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
ccfg.setAtomicityMode(atomicityMode);
ccfg.setCacheMode(cacheMode);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
ccfg.setEvictionPolicy(evictionPlc);
ccfg.setOnheapCacheEnabled(evictionPlc != null);
if (cacheMode == PARTITIONED)
ccfg.setBackups(1);
if (indexing)
ccfg.setIndexedTypes(TestKey.class, TestData.class);
return ccfg;
}
示例6: createCaches
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** */
@Before
public void createCaches() {
CacheConfiguration configuration = new CacheConfiguration<>();
configuration.setEvictionPolicy(new FifoEvictionPolicy(1));
createCache(firstCache, CacheAtomicityMode.TRANSACTIONAL, CacheMode.PARTITIONED, false, 0, configuration);
}
示例7: createCaches
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** */
@Before
public void createCaches() {
CacheConfiguration configuration = new CacheConfiguration<>();
configuration.setEvictionPolicy(new FifoEvictionPolicy(5));
createCache(firstCache, TRANSACTIONAL, PARTITIONED, false, 0, configuration);
configuration = new CacheConfiguration<>();
configuration.setEvictionPolicy(new FifoEvictionPolicy(101));
createCache(secondCache, TRANSACTIONAL, PARTITIONED, false, 0, configuration);
}
示例8: newCache
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Create new ML cache if needed.
*/
private IgniteCache<RowColMatrixKey, Map<Integer, Double>> newCache() {
CacheConfiguration<RowColMatrixKey, Map<Integer, Double>> cfg = new CacheConfiguration<>();
// Write to primary.
cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
// Atomic transactions only.
cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
// No eviction.
cfg.setEvictionPolicy(null);
// No copying of values.
cfg.setCopyOnRead(false);
// Cache is partitioned.
cfg.setCacheMode(CacheMode.PARTITIONED);
// TODO: Possibly we should add a fix of https://issues.apache.org/jira/browse/IGNITE-6862 here commented below.
// cfg.setReadFromBackup(false);
// Random cache name.
cfg.setName(CACHE_NAME);
return Ignition.localIgnite().getOrCreateCache(cfg);
}
示例9: IgniteCacheAdapter
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param id
* Cache id.
*/
@SuppressWarnings("unchecked")
public IgniteCacheAdapter(String id) {
if (id == null) {
throw new IllegalArgumentException("Cache instances require an ID");
}
CacheConfiguration<Object, Object> cacheCfg = null;
try {
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(new FileSystemResource(new File(CFG_PATH)));
cacheCfg = (CacheConfiguration<Object, Object>) factory.getBean("templateCacheCfg");
cacheCfg.setEvictionPolicy(null);
cacheCfg.setCacheLoaderFactory(null);
cacheCfg.setCacheWriterFactory(null);
// overrides template cache name with the specified id.
cacheCfg.setName(id);
} catch (NoSuchBeanDefinitionException | BeanDefinitionStoreException e) {
// initializes the default cache.
log.warn("Initializing the default cache. Consider properly configuring '" + CFG_PATH + "' instead.");
log.trace("" + e);
cacheCfg = new CacheConfiguration<>(id);
}
cache = ignite.getOrCreateCache(cacheCfg);
this.id = id;
}
示例10: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
TransactionConfiguration txCfg = c.getTransactionConfiguration();
txCfg.setDefaultTxConcurrency(txConcurrency);
txCfg.setDefaultTxIsolation(txIsolation);
txCfg.setTxSerializableEnabled(true);
CacheConfiguration cc = defaultCacheConfiguration();
cc.setCacheMode(cacheMode());
cc.setAtomicityMode(TRANSACTIONAL);
cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cc.setEvictionPolicy(plc);
cc.setOnheapCacheEnabled(true);
if (testStore != null) {
cc.setCacheStoreFactory(singletonFactory(testStore));
cc.setReadThrough(true);
cc.setWriteThrough(true);
cc.setLoadPreviousValue(true);
}
else
cc.setCacheStoreFactory(null);
c.setCacheConfiguration(cc);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
c.setDiscoverySpi(disco);
return c;
}
示例11: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的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;
}
示例12: defaultCacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @return New cache configuration with modified defaults.
*/
public static CacheConfiguration defaultCacheConfiguration() {
CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
cfg.setAtomicityMode(TRANSACTIONAL);
cfg.setNearConfiguration(new NearCacheConfiguration());
cfg.setWriteSynchronizationMode(FULL_SYNC);
cfg.setEvictionPolicy(null);
return cfg;
}
示例13: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@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;
}
示例14: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
cfg.setDiscoverySpi(disco);
CacheConfiguration<?,?> cacheCfg = defaultCacheConfiguration();
cacheCfg.setCacheMode(PARTITIONED);
cacheCfg.setAtomicityMode(TRANSACTIONAL);
cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cacheCfg.setBackups(0);
cacheCfg.setEvictionPolicy(null);
cacheCfg.setNearConfiguration(null);
cacheCfg.setIndexedTypes(
Integer.class, Integer.class
);
cfg.setCacheConfiguration(cacheCfg);
return cfg;
}
示例15: getOrCreate
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Get or create cache for training context.
*
* @param ignite Ignite instance.
* @param <D> Class storing information about continuous regions.
* @return Cache for training context.
*/
public static <D extends ContinuousRegionInfo> IgniteCache<UUID, TrainingContext<D>> getOrCreate(Ignite ignite) {
CacheConfiguration<UUID, TrainingContext<D>> cfg = new CacheConfiguration<>();
cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
cfg.setEvictionPolicy(null);
cfg.setCopyOnRead(false);
cfg.setCacheMode(CacheMode.REPLICATED);
cfg.setOnheapCacheEnabled(true);
cfg.setReadFromBackup(true);
cfg.setName(COLUMN_DECISION_TREE_TRAINER_CONTEXT_CACHE_NAME);
return ignite.getOrCreateCache(cfg);
}