use of org.apache.ignite.cache.store.CacheStore in project ignite by apache.
the class GridCacheStoreManagerAdapter method initialize.
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public void initialize(@Nullable CacheStore cfgStore, Map sesHolders) throws IgniteCheckedException {
GridKernalContext ctx = igniteContext();
CacheConfiguration cfg = cacheConfiguration();
writeThrough = cfg.isWriteThrough();
this.cfgStore = cfgStore;
store = cacheStoreWrapper(ctx, cfgStore, cfg);
singleThreadGate = store == null ? null : new CacheStoreBalancingWrapper<>(store, cfg.getStoreConcurrentLoadAllThreshold());
ThreadLocal<SessionData> sesHolder0 = null;
if (cfgStore != null) {
sesHolder0 = ((Map<CacheStore, ThreadLocal>) sesHolders).get(cfgStore);
if (sesHolder0 == null) {
sesHolder0 = new ThreadLocal<>();
locSes = new ThreadLocalSession(sesHolder0);
if (ctx.resource().injectStoreSession(cfgStore, locSes))
sesHolders.put(cfgStore, sesHolder0);
} else
locSes = new ThreadLocalSession(sesHolder0);
}
sesHolder = sesHolder0;
locStore = U.hasAnnotation(cfgStore, CacheLocalStore.class);
if (cfgStore instanceof CacheJdbcPojoStore)
alwaysKeepBinary = true;
}
use of org.apache.ignite.cache.store.CacheStore in project ignite by apache.
the class GridCacheEvictionTouchSelfTest method getConfiguration.
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
TransactionConfiguration txCfg = c.getTransactionConfiguration();
txCfg.setDefaultTxConcurrency(PESSIMISTIC);
txCfg.setDefaultTxIsolation(REPEATABLE_READ);
CacheConfiguration cc = defaultCacheConfiguration();
cc.setCacheMode(REPLICATED);
cc.setWriteSynchronizationMode(FULL_SYNC);
cc.setEvictionPolicy(plc);
cc.setOnheapCacheEnabled(true);
CacheStore store = new GridCacheGenericTestStore<Object, Object>() {
@Override
public Object load(Object key) {
return key;
}
@Override
public Map<Object, Object> loadAll(Iterable<?> keys) {
Map<Object, Object> loaded = new HashMap<>();
for (Object key : keys) loaded.put(key, key);
return loaded;
}
};
cc.setCacheStoreFactory(singletonFactory(store));
cc.setReadThrough(true);
cc.setWriteThrough(true);
cc.setLoadPreviousValue(true);
c.setCacheConfiguration(cc);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
c.setDiscoverySpi(disco);
return c;
}
Aggregations