本文整理汇总了Java中org.apache.ignite.cache.eviction.lru.LruEvictionPolicy类的典型用法代码示例。如果您正苦于以下问题:Java LruEvictionPolicy类的具体用法?Java LruEvictionPolicy怎么用?Java LruEvictionPolicy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LruEvictionPolicy类属于org.apache.ignite.cache.eviction.lru包,在下文中一共展示了LruEvictionPolicy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCacheCreateLeak
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testCacheCreateLeak() throws Exception {
final Ignite ignite = grid();
GridTestUtils.runMultiThreaded(new IgniteInClosure<Integer>() {
@Override public void apply(Integer idx) {
for (int i = 0; i < 100; i++) {
CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
ccfg.setName("cache-" + idx + "-" + i);
ccfg.setEvictionPolicy(new LruEvictionPolicy(1000));
ccfg.setOnheapCacheEnabled(true);
IgniteCache<Object, Object> cache = ignite.createCache(ccfg);
for (int k = 0; k < 5000; k++)
cache.put(k, new byte[1024]);
ignite.destroyCache(cache.getName());
}
}
}, 5, "cache-thread");
}
示例2: getConfiguration
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
CacheConfiguration<Integer, Integer> ccfg =
new CacheConfiguration<Integer, Integer>()
.setName("config")
.setAtomicityMode(CacheAtomicityMode.ATOMIC)
.setBackups(0) // No need for backup, just load from the store if needed
.setCacheStoreFactory(new CacheStoreFactory())
.setOnheapCacheEnabled(true)
.setEvictionPolicy(new LruEvictionPolicy(100))
.setNearConfiguration(new NearCacheConfiguration<Integer, Integer>()
.setNearEvictionPolicy(new LruEvictionPolicy<Integer, Integer>()));
ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 1)))
.setReadThrough(true)
.setWriteThrough(false);
cfg.setCacheConfiguration(ccfg);
return cfg;
}
示例3: getNearCacheConfig
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入依赖的package包/类
@Nullable
@SuppressWarnings("unchecked")
private NearCacheConfiguration getNearCacheConfig(ServerCacheType type, L2CacheConfig config) {
if (type.equals(ServerCacheType.QUERY) || config.getNearSize() == null) {
return null;
} else {
NearCacheConfiguration near = new NearCacheConfiguration();
near.setNearEvictionPolicy(new LruEvictionPolicy(config.getNearSize()));
return near;
}
}
示例4: getConfiguration
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入依赖的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;
}
示例5: testAtomicOffheapEviction
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testAtomicOffheapEviction() throws Exception {
CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
ATOMIC,
new LruEvictionPolicy<>(10),
false);
randomOperations(ccfg);
}
示例6: testAtomicOffheapEvictionIndexing
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testAtomicOffheapEvictionIndexing() throws Exception {
CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
ATOMIC,
new LruEvictionPolicy<>(10),
true);
randomOperations(ccfg);
}
示例7: testTxOffheapEviction
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testTxOffheapEviction() throws Exception {
CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
TRANSACTIONAL,
new LruEvictionPolicy<>(10),
false);
randomOperations(ccfg);
}
示例8: testTxOffheapEvictionIndexing
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testTxOffheapEvictionIndexing() throws Exception {
CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
TRANSACTIONAL,
new LruEvictionPolicy<>(10),
true);
randomOperations(ccfg);
}
示例9: testPartitionedOnlyAttributesIgnoredForReplicated
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testPartitionedOnlyAttributesIgnoredForReplicated() throws Exception {
cacheEnabled = true;
cacheMode = REPLICATED;
initCache = new C1<CacheConfiguration, Void>() {
@Override public Void apply(CacheConfiguration cfg) {
NearCacheConfiguration nearCfg = new NearCacheConfiguration();
nearCfg.setNearEvictionPolicyFactory(new FifoEvictionPolicyFactory<>());
nearCfg.setNearEvictionPolicy(new LruEvictionPolicy());
cfg.setNearConfiguration(nearCfg);
return null;
}
};
startGrid(1);
initCache = new C1<CacheConfiguration, Void>() {
@Override public Void apply(CacheConfiguration cfg) {
NearCacheConfiguration nearCfg = new NearCacheConfiguration();
nearCfg.setNearEvictionPolicyFactory(new FifoEvictionPolicyFactory<>());
nearCfg.setNearEvictionPolicy(new FifoEvictionPolicy());
cfg.setNearConfiguration(nearCfg);
return null;
}
};
startGrid(2);
}
示例10: 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;
}
示例11: testLocalCacheLruEvictionPolicy
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入依赖的package包/类
/** @throws Exception If failed. */
public void testLocalCacheLruEvictionPolicy() throws Exception {
cacheMode = LOCAL;
evictionPlc = new LruEvictionPolicy();
checkToString();
}
示例12: testReplicatedCacheLruEvictionPolicy
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入依赖的package包/类
/** @throws Exception If failed. */
public void testReplicatedCacheLruEvictionPolicy() throws Exception {
cacheMode = REPLICATED;
evictionPlc = new LruEvictionPolicy();
checkToString();
}
示例13: testPartitionedCacheLruEvictionPolicy
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入依赖的package包/类
/** @throws Exception If failed. */
public void testPartitionedCacheLruEvictionPolicy() throws Exception {
cacheMode = PARTITIONED;
nearEnabled = true;
evictionPlc = new LruEvictionPolicy();
checkToString();
}
示例14: testColocatedCacheLruEvictionPolicy
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入依赖的package包/类
/** @throws Exception If failed. */
public void testColocatedCacheLruEvictionPolicy() throws Exception {
cacheMode = PARTITIONED;
nearEnabled = false;
evictionPlc = new LruEvictionPolicy();
checkToString();
}
示例15: createNearPolicyFactory
import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected Factory<LruEvictionPolicy<String, String>> createNearPolicyFactory(int nearMax) {
LruEvictionPolicyFactory<String, String> plc = new LruEvictionPolicyFactory<>();
plc.setMaxSize(nearMax);
plc.setBatchSize(plcBatchSize);
return plc;
}