Java Code Examples for org.apache.ignite.configuration.CacheConfiguration#setLoadPreviousValue()

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration#setLoadPreviousValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GridCacheGetAndTransformStoreAbstractTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);

    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);

    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(cacheMode());
    cc.setWriteSynchronizationMode(FULL_SYNC);
    cc.setAtomicityMode(atomicityMode());
    cc.setRebalanceMode(SYNC);

    cc.setCacheStoreFactory(singletonFactory(store));
    cc.setReadThrough(true);
    cc.setWriteThrough(true);
    cc.setLoadPreviousValue(true);

    c.setCacheConfiguration(cc);

    return c;
}
 
Example 2
Source File: GridCacheBasicStoreAbstractTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);

    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);

    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(cacheMode());
    cc.setWriteSynchronizationMode(FULL_SYNC);
    cc.setAtomicityMode(atomicityMode());
    cc.setRebalanceMode(SYNC);

    cc.setCacheStoreFactory(singletonFactory(store));
    cc.setReadThrough(true);
    cc.setWriteThrough(true);
    cc.setLoadPreviousValue(true);

    c.setCacheConfiguration(cc);

    return c;
}
 
Example 3
Source File: GridCacheLocalLoadAllSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE);

    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setDiscoverySpi(disco);

    CacheConfiguration ccfg = defaultCacheConfiguration();

    ccfg.setName("test-cache");
    ccfg.setCacheMode(LOCAL);
    ccfg.setCacheStoreFactory(singletonFactory(new TestStore()));
    ccfg.setReadThrough(true);
    ccfg.setWriteThrough(true);
    ccfg.setLoadPreviousValue(true);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example 4
Source File: CacheJdbcStoreAbstractMultithreadedSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @return Cache configuration.
 * @throws Exception If failed.
 */
protected CacheConfiguration cacheConfiguration() throws Exception {
    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(PARTITIONED);
    cc.setAtomicityMode(ATOMIC);
    cc.setWriteBehindEnabled(false);

    cc.setCacheStoreFactory(singletonFactory(store));

    cc.setReadThrough(true);
    cc.setWriteThrough(true);
    cc.setLoadPreviousValue(true);

    return cc;
}
 
Example 5
Source File: GridCacheLoadOnlyStoreAdapterSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @return Cache configuration.
 */
@SuppressWarnings("unchecked")
private CacheConfiguration<?, ?> cacheConfiguration() {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);

    CacheConfiguration cfg = defaultCacheConfiguration();

    assertNotNull(store);

    cfg.setCacheStoreFactory(singletonFactory(store));
    cfg.setReadThrough(true);
    cfg.setWriteThrough(true);
    cfg.setLoadPreviousValue(true);

    return cfg;
}
 
Example 6
Source File: GridCacheAbstractTransformWriteThroughSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);

    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    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;
}
 
Example 7
Source File: CacheKeepBinaryIterationStoreEnabledTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheConfiguration<Object, Object> cacheConfiguration(
    CacheMode cacheMode,
    int backups,
    CacheAtomicityMode atomicityMode) {
    CacheConfiguration<Object, Object> ccfg =
        super.cacheConfiguration(cacheMode, backups, atomicityMode);

    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);

    ccfg.setCacheStoreFactory(singletonFactory(store));
    ccfg.setReadThrough(true);
    ccfg.setWriteThrough(true);
    ccfg.setLoadPreviousValue(true);

    return ccfg;
}
 
Example 8
Source File: GridCacheJdbcBlobStoreMultithreadedSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected final IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);

    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);

    if (!c.isClientMode()) {
        CacheConfiguration cc = defaultCacheConfiguration();

        cc.setCacheMode(PARTITIONED);
        cc.setWriteSynchronizationMode(FULL_SYNC);
        cc.setAtomicityMode(TRANSACTIONAL);
        cc.setBackups(1);

        cc.setCacheStoreFactory(new TestStoreFactory());
        cc.setReadThrough(true);
        cc.setWriteThrough(true);
        cc.setLoadPreviousValue(true);

        c.setCacheConfiguration(cc);
    }

    return c;
}
 
Example 9
Source File: IgniteCacheExpiryStoreLoadSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration cfg = super.cacheConfiguration(igniteInstanceName);

    cfg.setCacheStoreFactory(singletonFactory(new TestStore()));
    cfg.setReadThrough(true);
    cfg.setWriteThrough(true);
    cfg.setLoadPreviousValue(true);

    return cfg;
}
 
Example 10
Source File: IgniteTxStoreExceptionAbstractSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);

    CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName);

    ccfg.setCacheStoreFactory(singletonFactory(store));
    ccfg.setReadThrough(true);
    ccfg.setWriteThrough(true);
    ccfg.setLoadPreviousValue(true);

    return ccfg;
}
 
Example 11
Source File: GridCacheAbstractSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @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();

    if (storeStgy != null) {
        Factory<? extends CacheStore<Object, Object>> storeFactory = storeStgy.getStoreFactory();

        CacheStore<?, ?> store = storeFactory.create();

        if (store != null) {
            cfg.setCacheStoreFactory(storeFactory);
            cfg.setReadThrough(true);
            cfg.setWriteThrough(true);
            cfg.setLoadPreviousValue(true);
            storeStgy.updateCacheConfiguration(cfg);
        }
    }

    cfg.setCacheMode(cacheMode());
    cfg.setAtomicityMode(atomicityMode());
    cfg.setWriteSynchronizationMode(writeSynchronization());
    cfg.setNearConfiguration(nearConfiguration());
    cfg.setOnheapCacheEnabled(onheapCacheEnabled());

    Class<?>[] idxTypes = indexedTypes();

    if (!F.isEmpty(idxTypes))
        cfg.setIndexedTypes(idxTypes);

    if (cacheMode() == PARTITIONED)
        cfg.setBackups(backups());

    return cfg;
}
 
Example 12
Source File: GridCachePartitionedReloadAllAbstractSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);

    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;
}
 
Example 13
Source File: GridCacheTxLoadFromStoreOnLockSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
private void checkLoadedValue(int backups) throws Exception {
    CacheConfiguration<Integer, Integer> cacheCfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    cacheCfg.setCacheMode(CacheMode.PARTITIONED);
    cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
    cacheCfg.setCacheStoreFactory(new StoreFactory());
    cacheCfg.setReadThrough(true);
    cacheCfg.setBackups(backups);
    cacheCfg.setLoadPreviousValue(true);

    IgniteCache<Integer, Integer> cache = ignite(0).createCache(cacheCfg);

    for (int i = 0; i < 10; i++)
        assertEquals((Integer)i, cache.get(i));

    cache.removeAll();

    assertEquals(0, cache.size());

    for (TransactionConcurrency conc : TransactionConcurrency.values()) {
        for (TransactionIsolation iso : TransactionIsolation.values()) {
            info("Checking transaction [conc=" + conc + ", iso=" + iso + ']');

            try (Transaction tx = ignite(0).transactions().txStart(conc, iso)) {
                for (int i = 0; i < 10; i++)
                    assertEquals("Invalid value for transaction [conc=" + conc + ", iso=" + iso + ']',
                        (Integer)i, cache.get(i));

                tx.commit();
            }

            cache.removeAll();
            assertEquals(0, cache.size());
        }
    }

    cache.destroy();
}
 
Example 14
Source File: ClientAbstractSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param cacheName Cache name.
 * @return Cache configuration.
 * @throws Exception In case of error.
 */
@SuppressWarnings("unchecked")
private static CacheConfiguration cacheConfiguration(@NotNull final String cacheName) throws Exception {
    CacheConfiguration cfg = defaultCacheConfiguration();

    cfg.setCacheMode(DEFAULT_CACHE_NAME.equals(cacheName) || CACHE_NAME.equals(cacheName) ? LOCAL : "replicated".equals(cacheName) ?
        REPLICATED : PARTITIONED);
    cfg.setName(cacheName);
    cfg.setWriteSynchronizationMode(FULL_SYNC);

    cfg.setCacheStoreFactory(new Factory<CacheStore>() {
        @Override public CacheStore create() {
            synchronized (cacheStores) {
                HashMapStore cacheStore = cacheStores.get(cacheName);

                if (cacheStore == null)
                    cacheStores.put(cacheName, cacheStore = new HashMapStore());

                return cacheStore;
            }
        }
    });

    cfg.setWriteThrough(true);
    cfg.setReadThrough(true);
    cfg.setLoadPreviousValue(true);

    if (cfg.getCacheMode() == PARTITIONED)
        cfg.setBackups(1);

    return cfg;
}
 
Example 15
Source File: IgniteCacheNoReadThroughAbstractTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName);

    ccfg.setReadThrough(false);

    ccfg.setWriteThrough(true);

    ccfg.setLoadPreviousValue(true);

    return ccfg;
}
 
Example 16
Source File: IgniteCacheNoWriteThroughAbstractTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName);

    ccfg.setReadThrough(true);

    ccfg.setWriteThrough(false);

    ccfg.setLoadPreviousValue(true);

    return ccfg;
}
 
Example 17
Source File: IgniteCacheNoLoadPreviousValueAbstractTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName);

    ccfg.setReadThrough(true);

    ccfg.setWriteThrough(true);

    ccfg.setLoadPreviousValue(false);

    return ccfg;
}
 
Example 18
Source File: GridCacheBinaryStoreAbstractSelfTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    BinaryConfiguration bCfg = new BinaryConfiguration();

    bCfg.setNameMapper(new BinaryBasicNameMapper(false));
    bCfg.setIdMapper(new BinaryBasicIdMapper(false));

    bCfg.setClassNames(Arrays.asList(Key.class.getName(), Value.class.getName()));

    cfg.setBinaryConfiguration(bCfg);

    cfg.setMarshaller(new BinaryMarshaller());

    CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    cacheCfg.setCacheStoreFactory(singletonFactory(STORE));
    cacheCfg.setStoreKeepBinary(keepBinaryInStore());
    cacheCfg.setReadThrough(true);
    cacheCfg.setWriteThrough(true);
    cacheCfg.setLoadPreviousValue(true);

    cfg.setCacheConfiguration(cacheCfg);

    GridCacheBinaryStoreAbstractSelfTest.cfg = cfg;

    return cfg;
}
 
Example 19
Source File: GridCacheWriteBehindStoreAbstractTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected IgniteConfiguration getConfiguration() throws Exception {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);

    IgniteConfiguration c = super.getConfiguration();

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    c.setDiscoverySpi(disco);

    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(cacheMode());
    cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cc.setAtomicityMode(TRANSACTIONAL);

    cc.setCacheStoreFactory(singletonFactory(store));
    cc.setReadThrough(true);
    cc.setWriteThrough(true);
    cc.setLoadPreviousValue(true);

    cc.setWriteBehindEnabled(true);
    cc.setWriteBehindFlushFrequency(WRITE_FROM_BEHIND_FLUSH_FREQUENCY);

    c.setCacheConfiguration(cc);

    return c;
}
 
Example 20
Source File: GridCacheLifecycleAwareSelfTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected final IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setDiscoverySpi(new TcpDiscoverySpi());

    CacheConfiguration ccfg = defaultCacheConfiguration();

    ccfg.setCacheMode(PARTITIONED);

    ccfg.setWriteBehindEnabled(writeBehind);

    ccfg.setCacheMode(CacheMode.PARTITIONED);

    ccfg.setName(CACHE_NAME);

    TestStore store = new TestStore();

    ccfg.setCacheStoreFactory(singletonFactory(store));
    ccfg.setReadThrough(true);
    ccfg.setWriteThrough(true);
    ccfg.setLoadPreviousValue(true);

    lifecycleAwares.add(store.lifecycleAware);

    TestAffinityFunction affinity = new TestAffinityFunction();

    ccfg.setAffinity(affinity);

    lifecycleAwares.add(affinity);

    TestEvictionPolicy evictionPlc = new TestEvictionPolicy();

    ccfg.setEvictionPolicy(evictionPlc);
    ccfg.setOnheapCacheEnabled(true);

    lifecycleAwares.add(evictionPlc);

    if (near) {
        TestEvictionPolicy nearEvictionPlc = new TestEvictionPolicy();

        NearCacheConfiguration nearCfg = new NearCacheConfiguration();

        nearCfg.setNearEvictionPolicy(nearEvictionPlc);

        ccfg.setNearConfiguration(nearCfg);

        lifecycleAwares.add(nearEvictionPlc);
    }

    TestEvictionFilter evictionFilter = new TestEvictionFilter();

    ccfg.setEvictionFilter(evictionFilter);

    lifecycleAwares.add(evictionFilter);

    TestAffinityKeyMapper mapper = new TestAffinityKeyMapper();

    ccfg.setAffinityMapper(mapper);

    lifecycleAwares.add(mapper);

    TestInterceptor interceptor = new TestInterceptor();

    lifecycleAwares.add(interceptor);

    ccfg.setInterceptor(interceptor);

    TestTopologyValidator topValidator = new TestTopologyValidator();

    lifecycleAwares.add(topValidator);

    ccfg.setTopologyValidator(topValidator);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}