Search in sources :

Example 6 with CacheStore

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheStore(org.apache.ignite.cache.store.CacheStore) 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 7 with CacheStore

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;
}
Also used : CacheStore(org.apache.ignite.cache.store.CacheStore) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 8 with CacheStore

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

Example 9 with CacheStore

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheStore(org.apache.ignite.cache.store.CacheStore) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 10 with CacheStore

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) CacheStoreAdapter(org.apache.ignite.cache.store.CacheStoreAdapter) CacheStore(org.apache.ignite.cache.store.CacheStore) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) LruEvictionPolicy(org.apache.ignite.cache.eviction.lru.LruEvictionPolicy) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

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