Search in sources :

Example 21 with CacheStore

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;
}
Also used : GridKernalContext(org.apache.ignite.internal.GridKernalContext) CacheStore(org.apache.ignite.cache.store.CacheStore) CacheJdbcPojoStore(org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStore) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) CacheStoreBalancingWrapper(org.apache.ignite.internal.processors.cache.CacheStoreBalancingWrapper)

Example 22 with CacheStore

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;
}
Also used : TransactionConfiguration(org.apache.ignite.configuration.TransactionConfiguration) GridCacheGenericTestStore(org.apache.ignite.internal.processors.cache.GridCacheGenericTestStore) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) HashMap(java.util.HashMap) CacheStore(org.apache.ignite.cache.store.CacheStore) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

CacheStore (org.apache.ignite.cache.store.CacheStore)22 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)11 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)7 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)6 ClassPathResource (org.springframework.core.io.ClassPathResource)6 Map (java.util.Map)5 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)5 CacheEntryImpl (org.apache.ignite.internal.processors.cache.CacheEntryImpl)5 Test (org.junit.Test)5 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)3 Person (org.apache.ignite.tests.pojos.Person)3 Product (org.apache.ignite.tests.pojos.Product)3 ProductOrder (org.apache.ignite.tests.pojos.ProductOrder)3 Ignite (org.apache.ignite.Ignite)2 GridCacheTestStore (org.apache.ignite.internal.processors.cache.GridCacheTestStore)2 Transaction (org.apache.ignite.transactions.Transaction)2 SimpleStatement (com.datastax.driver.core.SimpleStatement)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1