本文整理汇总了Java中org.apache.ignite.configuration.CacheConfiguration.setReadThrough方法的典型用法代码示例。如果您正苦于以下问题:Java CacheConfiguration.setReadThrough方法的具体用法?Java CacheConfiguration.setReadThrough怎么用?Java CacheConfiguration.setReadThrough使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.configuration.CacheConfiguration
的用法示例。
在下文中一共展示了CacheConfiguration.setReadThrough方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCache
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Creates cache with full configuration. Active store is used.
*
* @param cacheName name of cache.
* @param atomicityMode atomicity.
* @param cacheMode mode.
* @param writeBehindEnabled should write behind be used for active store.
* @param flushFreq flush frequency for write behind.
* @param base configuration to copy settings from.
* @param <K> type of key.
* @param <V> type of value
* @return cache instance.
*/
@SuppressWarnings("unchecked")
public <K, V> IgniteCache<K, V> createCache(String cacheName, CacheAtomicityMode atomicityMode, CacheMode cacheMode,
boolean writeBehindEnabled, int flushFreq,
CacheConfiguration<K, V> base) {
CacheConfiguration<K, V> realConfiguration = base == null
? new CacheConfiguration<K, V>()
: new CacheConfiguration<K, V>(base);
realConfiguration.setName(cacheName);
realConfiguration.setAtomicityMode(atomicityMode);
realConfiguration.setCacheMode(cacheMode);
realConfiguration.setBackups(2);
realConfiguration.setWriteThrough(true);
realConfiguration.setReadThrough(true);
realConfiguration.setWriteBehindEnabled(writeBehindEnabled);
realConfiguration.setWriteBehindFlushFrequency(flushFreq);
realConfiguration.setCacheStoreFactory(activeStoreConfiguration.activeCacheStoreFactory());
return ignite().createCache(realConfiguration);
}
示例2: testGetFromBackupStoreReadThroughDisabled
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testGetFromBackupStoreReadThroughDisabled() throws Exception {
for (CacheConfiguration<Object, Object> ccfg : cacheConfigurations()) {
ccfg.setCacheStoreFactory(new TestStoreFactory());
ccfg.setReadThrough(false);
boolean near = (ccfg.getNearConfiguration() != null);
log.info("Test cache [mode=" + ccfg.getCacheMode() +
", atomicity=" + ccfg.getAtomicityMode() +
", backups=" + ccfg.getBackups() +
", near=" + near + "]");
ignite(0).createCache(ccfg);
awaitPartitionMapExchange();
try {
checkLocalRead(NODES, ccfg);
}
finally {
ignite(0).destroyCache(ccfg.getName());
}
}
}
示例3: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName);
ccfg.setWriteBehindEnabled(true);
ccfg.setWriteBehindBatchSize(10);
if (getTestIgniteInstanceName(2).equals(igniteInstanceName)) {
ccfg.setCacheStoreFactory(null);
ccfg.setWriteThrough(false);
ccfg.setReadThrough(false);
ccfg.setWriteBehindEnabled(false);
}
return ccfg;
}
示例4: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @param name Cache name.
* @param syncMode Write synchronization mode.
* @param backups Number of backups.
* @param store If {@code true} configures cache store.
* @return Cache configuration.
*/
private CacheConfiguration<Object, Object> cacheConfiguration(@NotNull String name,
CacheWriteSynchronizationMode syncMode,
int backups,
boolean store) {
CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
ccfg.setName(name);
ccfg.setAtomicityMode(TRANSACTIONAL);
ccfg.setWriteSynchronizationMode(syncMode);
ccfg.setBackups(backups);
if (store) {
ccfg.setCacheStoreFactory(new TestStoreFactory());
ccfg.setReadThrough(true);
ccfg.setWriteThrough(true);
}
return ccfg;
}
示例5: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
CacheConfiguration<String, Long> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
ccfg.setCacheMode(CacheMode.PARTITIONED);
ccfg.setBackups(1);
ccfg.setReadFromBackup(true);
ccfg.setCopyOnRead(false);
ccfg.setName(THROTTLES_CACHE_NAME);
Duration expiryDuration = new Duration(TimeUnit.MINUTES, 1);
ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(expiryDuration));
ccfg.setReadThrough(false);
ccfg.setWriteThrough(true);
ccfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory<>(new TestCacheStore()));
cfg.setCacheConfiguration(ccfg);
return cfg;
}
示例6: testEvictionWithReadThrough
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @param atomicityMode Atomicity mode.
* @param cacheMode Cache mode.
* @throws Exception If failed.
*/
private void testEvictionWithReadThrough(CacheAtomicityMode atomicityMode, CacheMode cacheMode) throws Exception {
startGrid(0);
CacheConfiguration<Object, Object> cfg = cacheConfig("evict-rebalance", null, cacheMode, atomicityMode,
CacheWriteSynchronizationMode.PRIMARY_SYNC);
cfg.setReadThrough(true);
cfg.setCacheStoreFactory(new TestStoreFactory());
IgniteCache<Object, Object> cache = ignite(0).getOrCreateCache(cfg);
for (int i = 1; i <= ENTRIES; i++) {
cache.get(i);
if (i % (ENTRIES / 10) == 0)
System.out.println(">>> Entries: " + i);
}
int size = cache.size(CachePeekMode.PRIMARY);
System.out.println(">>> Resulting size: " + size);
assertTrue(size > 0);
assertTrue(size < ENTRIES);
}
示例7: createCacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @param atomicityMode Atomicity mode.
* @return Cache configuration.
*/
@SuppressWarnings({"rawtypes", "unchecked"})
private CacheConfiguration<String, List<Double>> createCacheConfiguration(CacheAtomicityMode atomicityMode) {
CacheConfiguration<String, List<Double>> cc = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
cc.setCacheMode(PARTITIONED);
cc.setAtomicityMode(atomicityMode);
cc.setWriteSynchronizationMode(FULL_SYNC);
cc.setReadThrough(true);
cc.setWriteThrough(true);
Factory cacheStoreFactory = new FactoryBuilder.SingletonFactory(new DummyCacheStore());
cc.setCacheStoreFactory(cacheStoreFactory);
cc.setBackups(2);
return cc;
}
示例8: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @return Cache configuration.
*/
@NotNull private CacheConfiguration cacheConfiguration() {
CacheConfiguration cacheCfg = defaultCacheConfiguration();
cacheCfg.setName(CACHE_NAME);
cacheCfg.setCacheMode(cacheMode());
cacheCfg.setAtomicityMode(atomicityMode());
cacheCfg.setNearConfiguration(nearConfiguration());
cacheCfg.setRebalanceMode(ASYNC);
cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
cacheCfg.setCacheStoreFactory(new StoreFactory());
cacheCfg.setReadThrough(true);
cacheCfg.setWriteThrough(true);
cacheCfg.setLoadPreviousValue(true);
return cacheCfg;
}
示例9: prepareConfig
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static <K, V> IgniteConfiguration prepareConfig(HBaseCacheStoreSessionListener cssl,
HBaseCacheStore<K, V> cs, boolean writeBehind) {
IgniteConfiguration cfg = new IgniteConfiguration();
CacheConfiguration<K, V> cacheCfg = new CacheConfiguration<>();
cacheCfg.setWriteThrough(true);
cacheCfg.setWriteBehindEnabled(writeBehind);
cacheCfg.setReadThrough(true);
cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(cs));
cacheCfg.setCacheStoreSessionListenerFactories(FactoryBuilder.factoryOf(cssl));
cfg.setCacheConfiguration(cacheCfg);
return cfg;
}
示例10: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
CacheConfiguration ccfg = defaultCacheConfiguration();
ccfg.setCacheMode(REPLICATED);
ccfg.setCacheStoreFactory(singletonFactory(new TestStore()));
ccfg.setReadThrough(true);
ccfg.setWriteThrough(true);
ccfg.setLoadPreviousValue(true);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
ccfg.setIndexedTypes(
Integer.class, ValueObject.class
);
cfg.setCacheConfiguration(ccfg);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(IP_FINDER);
cfg.setDiscoverySpi(disco);
return cfg;
}
示例11: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @param cacheName Cache name.
* @return Cache configuration.
* @throws Exception In case of error.
*/
@SuppressWarnings("unchecked")
private static CacheConfiguration cacheConfiguration(@NotNull final String cacheName) throws Exception {
CacheConfiguration cfg = defaultCacheConfiguration();
cfg.setCacheMode(DEFAULT_CACHE_NAME.equals(cacheName) || CACHE_NAME.equals(cacheName) ? LOCAL : "replicated".equals(cacheName) ?
REPLICATED : PARTITIONED);
cfg.setName(cacheName);
cfg.setWriteSynchronizationMode(FULL_SYNC);
cfg.setCacheStoreFactory(new Factory<CacheStore>() {
@Override public CacheStore create() {
synchronized (cacheStores) {
HashMapStore cacheStore = cacheStores.get(cacheName);
if (cacheStore == null)
cacheStores.put(cacheName, cacheStore = new HashMapStore());
return cacheStore;
}
}
});
cfg.setWriteThrough(true);
cfg.setReadThrough(true);
cfg.setLoadPreviousValue(true);
if (cfg.getCacheMode() == PARTITIONED)
cfg.setBackups(1);
return cfg;
}
示例12: checkLoadedValue
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @throws Exception If failed.
*/
private void checkLoadedValue(int backups) throws Exception {
CacheConfiguration<Integer, Integer> cacheCfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
cacheCfg.setCacheMode(CacheMode.PARTITIONED);
cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
cacheCfg.setCacheStoreFactory(new StoreFactory());
cacheCfg.setReadThrough(true);
cacheCfg.setBackups(backups);
cacheCfg.setLoadPreviousValue(true);
IgniteCache<Integer, Integer> cache = ignite(0).createCache(cacheCfg);
for (int i = 0; i < 10; i++)
assertEquals((Integer)i, cache.get(i));
cache.removeAll();
assertEquals(0, cache.size());
for (TransactionConcurrency conc : TransactionConcurrency.values()) {
for (TransactionIsolation iso : TransactionIsolation.values()) {
info("Checking transaction [conc=" + conc + ", iso=" + iso + ']');
try (Transaction tx = ignite(0).transactions().txStart(conc, iso)) {
for (int i = 0; i < 10; i++)
assertEquals("Invalid value for transaction [conc=" + conc + ", iso=" + iso + ']',
(Integer)i, cache.get(i));
tx.commit();
}
cache.removeAll();
assertEquals(0, cache.size());
}
}
cache.destroy();
}
示例13: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @param cacheMode Cache mode.
* @param syncMode Write synchronization mode.
* @param backups Number of backups.
* @param storeEnabled If {@code true} adds cache store.
* @param nearCache If {@code true} near cache is enabled.
* @return Cache configuration.
*/
private CacheConfiguration<Integer, Integer> cacheConfiguration(
CacheMode cacheMode,
CacheWriteSynchronizationMode syncMode,
int backups,
boolean storeEnabled,
boolean nearCache) {
CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
ccfg.setCacheMode(cacheMode);
ccfg.setAtomicityMode(TRANSACTIONAL);
ccfg.setWriteSynchronizationMode(syncMode);
if (cacheMode == PARTITIONED)
ccfg.setBackups(backups);
if (storeEnabled) {
ccfg.setCacheStoreFactory(new TestStoreFactory());
ccfg.setWriteThrough(true);
ccfg.setReadThrough(true);
}
if (nearCache)
ccfg.setNearConfiguration(new NearCacheConfiguration<Integer, Integer>());
return ccfg;
}
示例14: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的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.setCacheMode(PARTITIONED);
cacheCfg.setNearConfiguration(null);
cacheCfg.setAffinity(new RendezvousAffinityFunction(false, 30));
cacheCfg.setBackups(1);
cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
if (storeEnabled) {
cacheCfg.setCacheStoreFactory(singletonFactory(new GridCacheTestStore()));
cacheCfg.setReadThrough(true);
cacheCfg.setWriteThrough(true);
cacheCfg.setLoadPreviousValue(true);
}
else
cacheCfg.setCacheStoreFactory(null);
cfg.setCacheConfiguration(cacheCfg);
return cfg;
}
示例15: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
CacheConfiguration cfg = super.cacheConfiguration(igniteInstanceName);
cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
cfg.setCacheMode(LOCAL);
cfg.setReadThrough(false);
return cfg;
}