use of org.apache.ignite.cache.store.CacheStore in project ignite by apache.
the class GridCacheGetStoreErrorSelfTest method getConfiguration.
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
c.setDiscoverySpi(disco);
CacheConfiguration cc = defaultCacheConfiguration();
cc.setCacheMode(cacheMode);
if (nearEnabled)
cc.setNearConfiguration(new NearCacheConfiguration());
cc.setAtomicityMode(TRANSACTIONAL);
cc.setCacheStoreFactory(new IgniteReflectionFactory<CacheStore>(TestStore.class));
cc.setReadThrough(true);
cc.setWriteThrough(true);
cc.setLoadPreviousValue(true);
c.setCacheConfiguration(cc);
c.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED);
return c;
}
use of org.apache.ignite.cache.store.CacheStore in project ignite by apache.
the class IgniteCacheAbstractTest method cacheConfiguration.
/**
* @param igniteInstanceName Ignite instance name.
* @return Cache configuration.
* @throws Exception In case of error.
*/
@SuppressWarnings("unchecked")
protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
CacheConfiguration cfg = defaultCacheConfiguration();
cfg.setCacheMode(cacheMode());
cfg.setAtomicityMode(atomicityMode());
cfg.setWriteSynchronizationMode(writeSynchronization());
cfg.setNearConfiguration(nearConfiguration());
cfg.setCacheLoaderFactory(loaderFactory());
if (cfg.getCacheLoaderFactory() != null)
cfg.setReadThrough(true);
cfg.setCacheWriterFactory(writerFactory());
if (cfg.getCacheWriterFactory() != null)
cfg.setWriteThrough(true);
Factory<CacheStore> storeFactory = cacheStoreFactory();
if (storeFactory != null) {
cfg.setCacheStoreFactory(storeFactory);
cfg.setReadThrough(true);
cfg.setWriteThrough(true);
cfg.setLoadPreviousValue(true);
}
if (cacheMode() == PARTITIONED)
cfg.setBackups(1);
cfg.setOnheapCacheEnabled(onheapCacheEnabled());
return cfg;
}
use of org.apache.ignite.cache.store.CacheStore in project ignite by apache.
the class GridCachePartitionedReloadAllAbstractSelfTest method getConfiguration.
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
c.setDiscoverySpi(disco);
CacheConfiguration cc = defaultCacheConfiguration();
if (!nearEnabled())
cc.setNearConfiguration(null);
cc.setCacheMode(cacheMode());
cc.setAtomicityMode(atomicityMode());
cc.setBackups(BACKUP_CNT);
cc.setWriteSynchronizationMode(FULL_SYNC);
CacheStore store = cacheStore();
if (store != null) {
cc.setCacheStoreFactory(singletonFactory(store));
cc.setReadThrough(true);
cc.setWriteThrough(true);
cc.setLoadPreviousValue(true);
} else
cc.setCacheStoreFactory(null);
c.setCacheConfiguration(cc);
return c;
}
use of org.apache.ignite.cache.store.CacheStore in project ignite by apache.
the class IgniteCacheStoreNodeRestartAbstractTest method getConfiguration.
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
// Use the same store instance for both caches.
CacheStore store = getStore();
assert cfg.getCacheConfiguration().length == 1;
CacheConfiguration ccfg0 = cfg.getCacheConfiguration()[0];
ccfg0.setReadThrough(true);
ccfg0.setWriteThrough(true);
ccfg0.setCacheStoreFactory(singletonFactory(store));
CacheConfiguration ccfg1 = cacheConfiguration(igniteInstanceName);
ccfg1.setReadThrough(true);
ccfg1.setWriteThrough(true);
ccfg1.setName(CACHE_NAME1);
ccfg1.setCacheStoreFactory(singletonFactory(store));
cfg.setCacheConfiguration(ccfg0, ccfg1);
return cfg;
}
use of org.apache.ignite.cache.store.CacheStore in project ignite by apache.
the class GridCacheReloadSelfTest method getConfiguration.
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setLocalHost("127.0.0.1");
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
ipFinder.setAddresses(Collections.singleton("127.0.0.1:47500"));
discoSpi.setIpFinder(ipFinder);
cfg.setDiscoverySpi(discoSpi);
CacheConfiguration cacheCfg = defaultCacheConfiguration();
cacheCfg.setName(CACHE_NAME);
cacheCfg.setCacheMode(cacheMode);
LruEvictionPolicy plc = new LruEvictionPolicy();
plc.setMaxSize(MAX_CACHE_ENTRIES);
cacheCfg.setEvictionPolicy(plc);
cacheCfg.setOnheapCacheEnabled(true);
cacheCfg.setNearConfiguration(nearEnabled ? new NearCacheConfiguration() : null);
final CacheStore store = new CacheStoreAdapter<Integer, Integer>() {
@Override
public Integer load(Integer key) {
return key;
}
@Override
public void write(javax.cache.Cache.Entry<? extends Integer, ? extends Integer> e) {
//No-op.
}
@Override
public void delete(Object key) {
//No-op.
}
};
cacheCfg.setCacheStoreFactory(singletonFactory(store));
cacheCfg.setReadThrough(true);
cacheCfg.setWriteThrough(true);
cacheCfg.setLoadPreviousValue(true);
if (cacheMode == PARTITIONED)
cacheCfg.setBackups(1);
cfg.setCacheConfiguration(cacheCfg);
return cfg;
}
Aggregations