Search in sources :

Example 1 with GridCacheGenericTestStore

use of org.apache.ignite.internal.processors.cache.GridCacheGenericTestStore in project ignite by apache.

the class GridCacheAbstractTransformWriteThroughSelfTest method getConfiguration.

/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    discoSpi.setIpFinder(IP_FINDER);
    cfg.setDiscoverySpi(discoSpi);
    GridCacheGenericTestStore<String, Integer> store = new GridCacheGenericTestStore<>();
    stores.add(store);
    CacheConfiguration cacheCfg = defaultCacheConfiguration();
    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setBackups(1);
    cacheCfg.setCacheStoreFactory(singletonFactory(store));
    cacheCfg.setReadThrough(true);
    cacheCfg.setWriteThrough(true);
    cacheCfg.setLoadPreviousValue(true);
    cacheCfg.setAtomicityMode(TRANSACTIONAL);
    cacheCfg.setNearConfiguration(new NearCacheConfiguration());
    cfg.setCacheConfiguration(cacheCfg);
    return cfg;
}
Also used : GridCacheGenericTestStore(org.apache.ignite.internal.processors.cache.GridCacheGenericTestStore) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 2 with GridCacheGenericTestStore

use of org.apache.ignite.internal.processors.cache.GridCacheGenericTestStore 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

CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)2 GridCacheGenericTestStore (org.apache.ignite.internal.processors.cache.GridCacheGenericTestStore)2 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)2 HashMap (java.util.HashMap)1 CacheStore (org.apache.ignite.cache.store.CacheStore)1 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)1 TransactionConfiguration (org.apache.ignite.configuration.TransactionConfiguration)1