Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-42 b0d8a67aa -> 5521dac5a


# ignite-42


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/5521dac5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/5521dac5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/5521dac5

Branch: refs/heads/ignite-42
Commit: 5521dac5a337ccdeb61d4a431b93bb18a11ff417
Parents: b0d8a67
Author: sboikov <sboi...@gridgain.com>
Authored: Fri Jan 16 17:37:57 2015 +0300
Committer: sboikov <sboi...@gridgain.com>
Committed: Fri Jan 16 17:37:57 2015 +0300

----------------------------------------------------------------------
 .../integration/GridClientAbstractSelfTest.java |   6 +-
 .../apache/ignite/cache/CacheConfiguration.java |  25 ++++-
 .../apache/ignite/cache/store/CacheStore.java   |   8 +-
 .../gridgain/grid/GridBasicWarmupClosure.java   |   2 +-
 .../processors/cache/GridCacheAdapter.java      |   2 +-
 .../processors/cache/GridCacheAttributes.java   |   8 +-
 .../processors/cache/GridCacheContext.java      |  14 +++
 .../processors/cache/GridCacheMapEntry.java     |   4 +-
 .../processors/cache/GridCacheProcessor.java    | 100 ++++++++++---------
 .../processors/cache/GridCacheStoreManager.java |  67 ++++++++++---
 .../cache/distributed/dht/GridDhtGetFuture.java |   4 +-
 .../dht/atomic/GridDhtAtomicCache.java          |  10 +-
 .../dht/atomic/GridNearAtomicUpdateFuture.java  |   2 +-
 .../colocated/GridDhtColocatedLockFuture.java   |   4 +-
 .../local/atomic/GridLocalAtomicCache.java      |  34 +++----
 .../processors/resource/GridResourceIoc.java    |  33 ++++--
 .../resource/GridResourceProcessor.java         |  20 ++++
 ...CacheJdbcBlobStoreMultithreadedSelfTest.java |   6 +-
 .../cache/IgniteCacheAbstractTest.java          |   9 +-
 .../GridCacheLoadOnlyStoreAdapterSelfTest.java  |   6 +-
 .../cache/GridCacheAbstractSelfTest.java        |  12 ++-
 .../cache/GridCacheAbstractTxReadTest.java      |   2 +-
 .../cache/GridCacheBasicStoreAbstractTest.java  |   7 +-
 ...acheBasicStoreMultithreadedAbstractTest.java |   6 +-
 ...idCacheConfigurationConsistencySelfTest.java |  58 +++++++++--
 ...idCacheGetAndTransformStoreAbstractTest.java |   7 +-
 ...CacheAtomicReferenceApiSelfAbstractTest.java |   6 +-
 .../dht/GridCacheColocatedDebugTest.java        |  12 ++-
 .../loadtests/hashmap/GridCacheTestContext.java |   3 +-
 29 files changed, 346 insertions(+), 131 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/clients/src/test/java/org/gridgain/client/integration/GridClientAbstractSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/clients/src/test/java/org/gridgain/client/integration/GridClientAbstractSelfTest.java
 
b/modules/clients/src/test/java/org/gridgain/client/integration/GridClientAbstractSelfTest.java
index 2fc2b88..6eb6184 100644
--- 
a/modules/clients/src/test/java/org/gridgain/client/integration/GridClientAbstractSelfTest.java
+++ 
b/modules/clients/src/test/java/org/gridgain/client/integration/GridClientAbstractSelfTest.java
@@ -39,6 +39,7 @@ import org.gridgain.testframework.junits.common.*;
 import org.jetbrains.annotations.*;
 
 import javax.cache.*;
+import javax.cache.configuration.*;
 import java.io.*;
 import java.util.*;
 import java.util.concurrent.*;
@@ -248,6 +249,7 @@ public abstract class GridClientAbstractSelfTest extends 
GridCommonAbstractTest
      * @return Cache configuration.
      * @throws Exception In case of error.
      */
+    @SuppressWarnings("unchecked")
     private CacheConfiguration cacheConfiguration(@Nullable String cacheName) 
throws Exception {
         CacheConfiguration cfg = defaultCacheConfiguration();
 
@@ -261,7 +263,9 @@ public abstract class GridClientAbstractSelfTest extends 
GridCommonAbstractTest
         if (cacheStore == null)
             cacheStores.put(cacheName, cacheStore = new HashMapStore());
 
-        cfg.setStore(cacheStore);
+        cfg.setCacheStoreFactory(new 
FactoryBuilder.SingletonFactory(cacheStore));
+        cfg.setWriteThrough(true);
+        cfg.setReadThrough(true);
 
         cfg.setSwapEnabled(true);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/main/java/org/apache/ignite/cache/CacheConfiguration.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/CacheConfiguration.java 
b/modules/core/src/main/java/org/apache/ignite/cache/CacheConfiguration.java
index cc51e9b..083ee79 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheConfiguration.java
@@ -33,6 +33,7 @@ import org.gridgain.grid.util.typedef.internal.*;
 import org.jetbrains.annotations.*;
 
 import javax.cache.configuration.*;
+import javax.cache.integration.*;
 import java.util.*;
 
 /**
@@ -236,7 +237,7 @@ public class CacheConfiguration extends 
MutableConfiguration {
     private GridCacheWriteSynchronizationMode writeSync;
 
     /** */
-    private CacheStore<?, ?> store;
+    private Factory storeFactory;
 
     /** Node group resolver. */
     private GridCacheAffinityFunction aff;
@@ -400,7 +401,7 @@ public class CacheConfiguration extends 
MutableConfiguration {
         qryIdxEnabled = cc.isQueryIndexEnabled();
         seqReserveSize = cc.getAtomicSequenceReserveSize();
         startSize = cc.getStartSize();
-        store = cc.getStore();
+        storeFactory = cc.getCacheStoreFactory();
         storeValBytes = cc.isStoreValueBytes();
         swapEnabled = cc.isSwapEnabled();
         tmLookupClsName = cc.getTransactionManagerLookupClassName();
@@ -795,7 +796,7 @@ public class CacheConfiguration extends 
MutableConfiguration {
      */
     @SuppressWarnings({"unchecked"})
     public <K, V> CacheStore<K, V> getStore() {
-        return (CacheStore<K, V>)store;
+        return null;//(CacheStore<K, V>)store;
     }
 
     /**
@@ -804,7 +805,23 @@ public class CacheConfiguration extends 
MutableConfiguration {
      * @param store Persistent cache store.
      */
     public <K, V> void setStore(CacheStore<K, V> store) {
-        this.store = store;
+        //this.store = store;
+    }
+
+    /**
+     * @return Cache store factory.
+     */
+    @SuppressWarnings("unchecked")
+    public <K, V> Factory<CacheStore<? super K, ? super V>> 
getCacheStoreFactory() {
+        return (Factory<CacheStore<? super K, ? super V>>)storeFactory;
+    }
+
+    /**
+     * @param storeFactory Cache store factory.
+     */
+    @SuppressWarnings("unchecked")
+    public <K, V> void setCacheStoreFactory(Factory<? extends CacheStore<? 
super K, ? super V>> storeFactory) {
+        this.storeFactory = storeFactory;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java 
b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java
index f44d79a..7d845e6 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.cache.store;
 
 import org.apache.ignite.IgnitePortables;
+import org.apache.ignite.cache.CacheConfiguration;
 import org.apache.ignite.cache.store.jdbc.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.portables.*;
@@ -35,7 +36,7 @@ import static javax.cache.Cache.*;
 
 /**
  * API for cache persistent storage for read-through and write-through 
behavior.
- * Persistent store is configured via {@link 
org.apache.ignite.cache.CacheConfiguration#getStore()}
+ * Persistent store is configured via {@link 
CacheConfiguration#getCacheStoreFactory()}
  * configuration property. If not provided, values will be only kept in cache 
memory
  * or swap storage without ever being persisted to a persistent storage.
  * <p>
@@ -70,7 +71,7 @@ import static javax.cache.Cache.*;
  * }
  * </pre>
  * <h1 class="header">Working With Portable Objects</h1>
- * When portables are enabled for cache by setting {@link 
org.apache.ignite.cache.CacheConfiguration#isPortableEnabled()} to
+ * When portables are enabled for cache by setting {@link 
CacheConfiguration#isPortableEnabled()} to
  * {@code true}), all portable keys and values are converted to instances of 
{@link PortableObject}.
  * Therefore, all cache store methods will take parameters in portable format. 
To avoid class
  * cast exceptions, store must have signature compatible with portables. E.g., 
if you use {@link Integer}
@@ -85,7 +86,7 @@ import static javax.cache.Cache.*;
  *     ...
  * }
  * </pre>
- * This behavior can be overridden by setting {@link 
org.apache.ignite.cache.CacheConfiguration#setKeepPortableInStore(boolean)}
+ * This behavior can be overridden by setting {@link 
CacheConfiguration#setKeepPortableInStore(boolean)}
  * flag value to {@code false}. In this case, GridGain will deserialize keys 
and values stored in portable
  * format before they are passed to cache store, so that you can use the 
following cache store signature instead:
  * <pre name="code" class="java">
@@ -118,6 +119,7 @@ import static javax.cache.Cache.*;
  * </ul>
  *
  * @see IgnitePortables
+ * @see CacheStoreSession
  */
 public interface CacheStore<K, V> extends CacheLoader<K, V>, CacheWriter<K, V> 
{
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/main/java/org/gridgain/grid/GridBasicWarmupClosure.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/GridBasicWarmupClosure.java 
b/modules/core/src/main/java/org/gridgain/grid/GridBasicWarmupClosure.java
index 40b94e8..51ab98a 100644
--- a/modules/core/src/main/java/org/gridgain/grid/GridBasicWarmupClosure.java
+++ b/modules/core/src/main/java/org/gridgain/grid/GridBasicWarmupClosure.java
@@ -356,7 +356,7 @@ public class GridBasicWarmupClosure implements 
IgniteInClosure<IgniteConfigurati
                 else if (ccfgCp.getDistributionMode() == 
GridCacheDistributionMode.NEAR_ONLY)
                     
ccfgCp.setDistributionMode(GridCacheDistributionMode.NEAR_PARTITIONED);
 
-                ccfgCp.setStore(null);
+                ccfgCp.setCacheStoreFactory(null);
                 ccfgCp.setWriteBehindEnabled(false);
 
                 reduced.add(ccfgCp);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAdapter.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAdapter.java
index 2275c88..a8a71e2 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAdapter.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAdapter.java
@@ -1892,7 +1892,7 @@ public abstract class GridCacheAdapter<K, V> extends 
GridMetadataAwareAdapter im
                     }
                 }
 
-                if (misses != null && ctx.isStoreEnabled()) {
+                if (misses != null && ctx.readThrough()) {
                     final Map<K, GridCacheVersion> loadKeys = misses;
 
                     final Collection<K> redos = new LinkedList<>();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAttributes.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAttributes.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAttributes.java
index 906ed53..da76ecc 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAttributes.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAttributes.java
@@ -18,6 +18,7 @@
 package org.gridgain.grid.kernal.processors.cache;
 
 import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.store.*;
 import org.gridgain.grid.cache.*;
 import org.gridgain.grid.cache.affinity.*;
 import org.gridgain.grid.cache.affinity.consistenthash.*;
@@ -155,8 +156,9 @@ public class GridCacheAttributes implements Externalizable {
 
     /**
      * @param cfg Cache configuration.
+     * @param store Cache store.
      */
-    public GridCacheAttributes(CacheConfiguration cfg) {
+    public GridCacheAttributes(CacheConfiguration cfg, @Nullable CacheStore<?, 
?> store) {
         atomicityMode = cfg.getAtomicityMode();
         cacheMode = cfg.getCacheMode();
         dfltLockTimeout = cfg.getDefaultLockTimeout();
@@ -171,7 +173,7 @@ public class GridCacheAttributes implements Externalizable {
         preloadMode = cfg.getPreloadMode();
         qryIdxEnabled = cfg.isQueryIndexEnabled();
         seqReserveSize = cfg.getAtomicSequenceReserveSize();
-        storeEnabled = cfg.getStore() != null;
+        storeEnabled = store != null;
         storeValBytes = cfg.isStoreValueBytes();
         swapEnabled = cfg.isSwapEnabled();
         ttl = cfg.getDefaultTimeToLive();
@@ -206,7 +208,7 @@ public class GridCacheAttributes implements Externalizable {
         evictFilterClsName = className(cfg.getEvictionFilter());
         evictPlcClsName = className(cfg.getEvictionPolicy());
         nearEvictPlcClsName = className(cfg.getNearEvictionPolicy());
-        storeClsName = className(cfg.getStore());
+        storeClsName = className(store);
         tmLookupClsName = cfg.getTransactionManagerLookupClassName();
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheContext.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheContext.java
index 2a5988f..e05a7c1 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheContext.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheContext.java
@@ -1406,6 +1406,20 @@ public class GridCacheContext<K, V> implements 
Externalizable {
     }
 
     /**
+     * @return {@code True} if store read-through mode is enabled.
+     */
+    public boolean readThrough() {
+        return cacheCfg.isReadThrough() && !hasFlag(SKIP_STORE);
+    }
+
+    /**
+     * @return {@code True} if store write-through is enabled.
+     */
+    public boolean writeThrough() {
+        return cacheCfg.isWriteThrough() && !hasFlag(SKIP_STORE);
+    }
+
+    /**
      * @return {@code True} if invalidation is enabled.
      */
     public boolean isInvalidate() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
index d4987e3..7f66ae0 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
@@ -673,7 +673,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
         @Nullable IgniteCacheExpiryPolicy expiryPlc)
         throws IgniteCheckedException, GridCacheEntryRemovedException, 
GridCacheFilterFailedException {
         // Disable read-through if there is no store.
-        if (readThrough && !cctx.isStoreEnabled())
+        if (readThrough && !cctx.readThrough())
             readThrough = false;
 
         GridCacheMvccCandidate<K> owner;
@@ -1705,7 +1705,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
             if (drRes == null) { // Perform version check only in case there 
will be no explicit conflict resolution.
                 if (verCheck) {
                     if (!isNew() && ATOMIC_VER_COMPARATOR.compare(ver, newVer) 
>= 0) {
-                        if (ATOMIC_VER_COMPARATOR.compare(ver, newVer) == 0 && 
cctx.isStoreEnabled() && primary) {
+                        if (ATOMIC_VER_COMPARATOR.compare(ver, newVer) == 0 && 
cctx.writeThrough() && primary) {
                             if (log.isDebugEnabled())
                                 log.debug("Received entry update with same 
version as current (will update store) " +
                                     "[entry=" + this + ", newVer=" + newVer + 
']');

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
index 1eec684..5564520 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
@@ -130,9 +130,10 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
 
     /**
      * @param cfg Initializes cache configuration with proper defaults.
+     * @throws IgniteCheckedException If configuration is not valid.
      */
     @SuppressWarnings("unchecked")
-    private void initialize(CacheConfiguration cfg) {
+    private void initialize(CacheConfiguration cfg) throws 
IgniteCheckedException {
         if (cfg.getCacheMode() == null)
             cfg.setCacheMode(DFLT_CACHE_MODE);
 
@@ -220,7 +221,7 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
             }
         }
 
-        if (cfg.getStore() == null) {
+        if (cfg.getCacheStoreFactory() == null) {
             Factory<CacheLoader> ldrFactory = cfg.getCacheLoaderFactory();
 
             CacheLoader ldr = null;
@@ -235,15 +236,32 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
             if (cfg.isWriteThrough() && writerFactory != null)
                 writer = writerFactory.create();
 
-            if (ldr != null || writer != null)
-                cfg.setStore(new GridCacheLoaderWriterStore(ldr, writer));
+            if (ldr != null || writer != null) {
+                final GridCacheLoaderWriterStore store = new 
GridCacheLoaderWriterStore(ldr, writer);
+
+                cfg.setCacheStoreFactory(new Factory<CacheStore<? super 
Object, ? super Object>>() {
+                    @Override public CacheStore<? super Object, ? super 
Object> create() {
+                        return store;
+                    }
+                });
+            }
+        }
+        else {
+            if (cfg.getCacheLoaderFactory() != null)
+                throw new IgniteCheckedException("Cannot set both cache loaded 
factory and cache store factory " +
+                    "for cache: " + cfg.getName());
+
+            if (cfg.getCacheWriterFactory() != null)
+                throw new IgniteCheckedException("Cannot set both cache writer 
factory and cache store factory " +
+                    "for cache: " + cfg.getName());
         }
     }
 
     /**
      * @param cfg Configuration to check for possible performance issues.
+     * @param hasStore {@code True} if store is configured.
      */
-    private void suggestOptimizations(CacheConfiguration cfg) {
+    private void suggestOptimizations(CacheConfiguration cfg, boolean 
hasStore) {
         GridPerformanceSuggestions perf = ctx.performance();
 
         String msg = "Disable eviction policy (remove from configuration)";
@@ -276,7 +294,7 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
         // Suppress warning if at least one swap is disabled.
         perf.add("Disable swap store (set 'swapEnabled' to false)", 
!cfg.isSwapEnabled());
 
-        if (cfg.getStore() != null)
+        if (hasStore && cfg.isWriteThrough())
             perf.add("Enable write-behind to persistent store (set 
'writeBehindEnabled' to true)",
                 cfg.isWriteBehindEnabled());
 
@@ -286,9 +304,12 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
     /**
      * @param c Grid configuration.
      * @param cc Configuration to validate.
+     * @param cfgStore Cache store.
      * @throws IgniteCheckedException If failed.
      */
-    private void validate(IgniteConfiguration c, CacheConfiguration cc) throws 
IgniteCheckedException {
+    private void validate(IgniteConfiguration c,
+        CacheConfiguration cc,
+        @Nullable CacheStore cfgStore) throws IgniteCheckedException {
         if (cc.getCacheMode() == REPLICATED) {
             if (cc.getAffinity() instanceof GridCachePartitionFairAffinity)
                 throw new IgniteCheckedException("REPLICATED cache can not be 
started with GridCachePartitionFairAffinity" +
@@ -351,9 +372,9 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
                     "for cache: " + cc.getName());
 
         if (cc.isWriteBehindEnabled()) {
-            if (cc.getStore() == null)
-                throw new IgniteCheckedException("Cannot enable write-behind 
cache (cache store is not provided) for cache: " +
-                    cc.getName());
+            if (cfgStore == null)
+                throw new IgniteCheckedException("Cannot enable write-behind 
(write or store is not provided) " +
+                    "for cache: " + cc.getName());
 
             assertParameter(cc.getWriteBehindBatchSize() > 0, 
"writeBehindBatchSize > 0");
             assertParameter(cc.getWriteBehindFlushSize() >= 0, 
"writeBehindFlushSize >= 0");
@@ -365,6 +386,14 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
                     "'writeBehindFlushSize' parameters to 0 for cache: " + 
cc.getName());
         }
 
+        if (cc.isReadThrough() && cfgStore == null)
+            throw new IgniteCheckedException("Cannot enable read-through 
(loader or store is not provided) " +
+                "for cache: " + cc.getName());
+
+        if (cc.isWriteThrough() && cfgStore == null)
+            throw new IgniteCheckedException("Cannot enable read-through 
(writer or store is not provided) " +
+                "for cache: " + cc.getName());
+
         long delay = cc.getPreloadPartitionedDelay();
 
         if (delay != 0) {
@@ -470,7 +499,6 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
         prepare(cfg, cfg.getAffinity(), false);
         prepare(cfg, cfg.getAffinityMapper(), false);
         prepare(cfg, cfg.getCloner(), false);
-        prepare(cfg, cfg.getStore(), false);
         prepare(cfg, cfg.getEvictionFilter(), false);
         prepare(cfg, cfg.getInterceptor(), false);
 
@@ -506,7 +534,7 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
         cleanup(cfg, cfg.getAffinityMapper(), false);
         cleanup(cfg, cctx.jta().tmLookup(), false);
         cleanup(cfg, cfg.getCloner(), false);
-        cleanup(cfg, cfg.getStore(), false);
+        cleanup(cfg, cctx.store().configuredStore(), false);
 
         cctx.cleanup();
     }
@@ -576,19 +604,21 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
             // Initialize defaults.
             initialize(cfg);
 
-            // Skip suggestions for system caches.
-            if (!sysCaches.contains(cfg.getName()))
-                suggestOptimizations(cfg);
+            CacheStore cfgStore = cfg.getCacheStoreFactory() != null ? 
cfg.getCacheStoreFactory().create() : null;
 
-            validate(ctx.config(), cfg);
+            validate(ctx.config(), cfg, cfgStore);
 
             GridCacheJtaManagerAdapter jta = 
JTA.create(cfg.getTransactionManagerLookupClassName() == null);
 
             jta.createTmLookup(cfg);
 
-            prepare(cfg, jta.tmLookup());
+            // Skip suggestions for system caches.
+            if (!sysCaches.contains(cfg.getName()))
+                suggestOptimizations(cfg, cfgStore != null);
 
-            U.startLifecycleAware(lifecycleAwares(cfg, jta.tmLookup()));
+            prepare(cfg, jta.tmLookup(), cfgStore);
+
+            U.startLifecycleAware(lifecycleAwares(cfg, jta.tmLookup(), 
cfgStore));
 
             cfgs[i] = cfg; // Replace original configuration value.
 
@@ -602,9 +632,7 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
             GridCacheTtlManager ttlMgr = new GridCacheTtlManager();
             GridCacheDrManager drMgr = 
ctx.createComponent(GridCacheDrManager.class);
 
-            CacheStore store = cacheStore(ctx.gridName(), cfg);
-
-            GridCacheStoreManager storeMgr = new GridCacheStoreManager(ctx, 
store);
+            GridCacheStoreManager storeMgr = new GridCacheStoreManager(ctx, 
cfgStore, cfg);
 
             GridCacheContext<?, ?> cacheCtx = new GridCacheContext(
                 ctx,
@@ -923,7 +951,11 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
         int i = 0;
 
         for (CacheConfiguration cfg : ctx.config().getCacheConfiguration()) {
-            attrVals[i++] = new GridCacheAttributes(cfg);
+            assert caches.containsKey(cfg.getName()) : cfg.getName();
+
+            GridCacheContext ctx = caches.get(cfg.getName()).context();
+
+            attrVals[i++] = new GridCacheAttributes(cfg, 
ctx.store().configuredStore());
 
             attrPortable.put(CU.mask(cfg.getName()), cfg.isPortableEnabled());
 
@@ -1804,30 +1836,6 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
     }
 
     /**
-     * Creates a wrapped cache store if write-behind cache is configured.
-     *
-     * @param gridName Grid name.
-     * @param cfg Cache configuration.
-     * @return Instance if {@link GridCacheWriteBehindStore} if write-behind 
store is configured,
-     *         or user-defined cache store.
-     */
-    @SuppressWarnings({"unchecked"})
-    private CacheStore cacheStore(String gridName, CacheConfiguration cfg) {
-        if (cfg.getStore() == null || !cfg.isWriteBehindEnabled())
-            return cfg.getStore();
-
-        GridCacheWriteBehindStore store = new 
GridCacheWriteBehindStore(gridName, cfg.getName(), log,
-            cfg.getStore());
-
-        store.setFlushSize(cfg.getWriteBehindFlushSize());
-        store.setFlushThreadCount(cfg.getWriteBehindFlushThreadCount());
-        store.setFlushFrequency(cfg.getWriteBehindFlushFrequency());
-        store.setBatchSize(cfg.getWriteBehindBatchSize());
-
-        return store;
-    }
-
-    /**
      * @param ccfg Cache configuration.
      * @param objs Extra components.
      * @return Components provided in cache configuration which can implement 
{@link LifecycleAware} interface.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheStoreManager.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheStoreManager.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheStoreManager.java
index f08dcb5..9649ba5 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheStoreManager.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheStoreManager.java
@@ -18,12 +18,14 @@
 package org.gridgain.grid.kernal.processors.cache;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.store.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.lifecycle.*;
 import org.apache.ignite.resources.*;
 import org.apache.ignite.transactions.*;
 import org.gridgain.grid.*;
+import org.gridgain.grid.cache.*;
 import org.gridgain.grid.kernal.*;
 import org.gridgain.grid.kernal.processors.interop.*;
 import org.gridgain.grid.util.lang.*;
@@ -34,6 +36,8 @@ import org.jetbrains.annotations.*;
 import javax.cache.*;
 import java.util.*;
 
+import static org.gridgain.grid.cache.GridCacheAtomicityMode.*;
+
 /**
  * Store manager.
  */
@@ -45,6 +49,9 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
     private final CacheStore<K, Object> store;
 
     /** */
+    private final CacheStore<?, ?> cfgStore;
+
+    /** */
     private final CacheStoreBalancingWrapper<K, Object> singleThreadGate;
 
     /** */
@@ -61,28 +68,62 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
 
     /**
      * @param ctx Kernal context.
-     * @param store Store.
+     * @param cfgStore Store provided in configuration.
+     * @param cfg Cache configuration.
      * @throws IgniteCheckedException In case of error.
      */
     @SuppressWarnings("unchecked")
-    public GridCacheStoreManager(GridKernalContext ctx, @Nullable 
CacheStore<K, Object> store)
-        throws IgniteCheckedException {
-        this.store = store;
+    public GridCacheStoreManager(GridKernalContext ctx,
+        @Nullable CacheStore<K, Object> cfgStore,
+        CacheConfiguration cfg) throws IgniteCheckedException {
+        this.cfgStore = cfgStore;
+
+        store = cacheStoreWrapper(ctx.gridName(), cfgStore, cfg);
 
         singleThreadGate = store == null ? null : new 
CacheStoreBalancingWrapper<>(store);
 
-        if (store instanceof GridCacheWriteBehindStore)
-            store = ((GridCacheWriteBehindStore)store).store();
+        boolean sesEnabled0 = false;
 
-        if (store != null) {
-            ctx.resource().injectBasicResource(store, 
IgniteCacheSessionResource.class, new ThreadLocalSession());
+        if (cfgStore != null && cfg.getAtomicityMode() == TRANSACTIONAL)
+            sesEnabled0 = ctx.resource().injectStoreSession(cfgStore, new 
ThreadLocalSession());
 
-            sesEnabled = true; // TODO IGNITE-42.
-        }
-        else
-            sesEnabled = false;
+        sesEnabled = sesEnabled0;
 
-        locStore = U.hasAnnotation(store, CacheLocalStore.class);
+        locStore = U.hasAnnotation(cfgStore, CacheLocalStore.class);
+    }
+
+    /**
+     * @return Unwrapped store provided in configuration.
+     */
+    public CacheStore<?, ?> configuredStore() {
+        return cfgStore;
+    }
+
+    /**
+     * Creates a wrapped cache store if write-behind cache is configured.
+     *
+     * @param gridName Grid name.
+     * @param cfgStore Store provided in configuration.
+     * @param cfg Cache configuration.
+     * @return Instance if {@link GridCacheWriteBehindStore} if write-behind 
store is configured,
+     *         or user-defined cache store.
+     */
+    @SuppressWarnings({"unchecked"})
+    private CacheStore cacheStoreWrapper(String gridName, @Nullable CacheStore 
cfgStore, CacheConfiguration cfg) {
+        if (cfgStore == null || !cfg.isWriteBehindEnabled())
+            return cfgStore;
+
+        GridCacheWriteBehindStore store = new 
GridCacheWriteBehindStore(gridName,
+            cfg.getName(),
+            log,
+            cfgStore);
+
+        store.setFlushSize(cfg.getWriteBehindFlushSize());
+        store.setFlushThreadCount(cfg.getWriteBehindFlushThreadCount());
+        store.setFlushFrequency(cfg.getWriteBehindFlushFrequency());
+        store.setBatchSize(cfg.getWriteBehindBatchSize());
+
+        return store;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtGetFuture.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtGetFuture.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtGetFuture.java
index 6642690..c65ecdd 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtGetFuture.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtGetFuture.java
@@ -343,7 +343,7 @@ public final class GridDhtGetFuture<K, V> extends 
GridCompoundIdentityFuture<Col
         IgniteFuture<Map<K, V>> fut;
 
         if (txFut == null || txFut.isDone()) {
-            if (reload && cctx.isStoreEnabled() && cctx.store().configured()) {
+            if (reload && cctx.readThrough() && cctx.store().configured()) {
                 fut = cache().reloadAllAsync(keys.keySet(),
                     true,
                     subjId,
@@ -379,7 +379,7 @@ public final class GridDhtGetFuture<K, V> extends 
GridCompoundIdentityFuture<Col
                         if (e != null)
                             throw new GridClosureException(e);
 
-                        if (reload && cctx.isStoreEnabled() && 
cctx.store().configured()) {
+                        if (reload && cctx.readThrough() && 
cctx.store().configured()) {
                             return cache().reloadAllAsync(keys.keySet(),
                                 true,
                                 subjId,

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index c3f1bf5..8064b46 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -534,8 +534,8 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
     /**
      * @return {@code True} if store enabled.
      */
-    private boolean storeEnabled() {
-        return ctx.isStoreEnabled() && ctx.config().getStore() != null;
+    private boolean writeThrough() {
+        return ctx.writeThrough() && ctx.store().configured();
     }
 
     /**
@@ -1077,7 +1077,7 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
                         if (plc != null)
                             expiry = new UpdateExpiryPolicy(plc);
 
-                        if (storeEnabled() && keys.size() > 1 && 
!ctx.dr().receiveEnabled()) {
+                        if (writeThrough() && keys.size() > 1 && 
!ctx.dr().receiveEnabled()) {
                             // This method can only be used when there are no 
replicated entries in the batch.
                             UpdateBatchResult<K, V> updRes = 
updateWithBatch(node,
                                 hasNear,
@@ -1650,7 +1650,7 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
                     writeVal,
                     newValBytes,
                     req.invokeArguments(),
-                    primary && storeEnabled(),
+                    primary && writeThrough(),
                     req.returnValue(),
                     expiry,
                     true,
@@ -2500,7 +2500,7 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
     @SuppressWarnings("ForLoopReplaceableByForEach")
     private void 
checkClearForceTransformBackups(GridNearAtomicUpdateRequest<K, V> req,
         List<GridDhtCacheEntry<K, V>> locked) {
-        if (ctx.isStoreEnabled() && req.operation() == TRANSFORM) {
+        if (ctx.writeThrough() && req.operation() == TRANSFORM) {
             for (int i = 0; i < locked.size(); i++) {
                 if (!locked.get(i).hasValue()) {
                     req.forceTransformBackups(false);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
index cd004e2..3443f86 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
@@ -230,7 +230,7 @@ public class GridNearAtomicUpdateFuture<K, V> extends 
GridFutureAdapter<Object>
 
         fastMap = F.isEmpty(filter) && op != TRANSFORM && 
cctx.config().getWriteSynchronizationMode() == FULL_SYNC &&
             cctx.config().getAtomicWriteOrderMode() == CLOCK &&
-            !(cctx.isStoreEnabled() && cctx.config().getInterceptor() != null);
+            !(cctx.writeThrough() && cctx.config().getInterceptor() != null);
 
         nearEnabled = CU.isNearEnabled(cctx);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
index 9542c85..693ecb0 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
@@ -750,7 +750,7 @@ public final class GridDhtColocatedLockFuture<K, V> extends 
GridCompoundIdentity
 
                                 distributedKeys.add(key);
 
-                                if (inTx() && implicitTx() && mappings.size() 
== 1 && !cctx.isStoreEnabled()) {
+                                if (inTx() && implicitTx() && mappings.size() 
== 1 && !cctx.writeThrough()) {
                                     tx.onePhaseCommit(true);
 
                                     req.onePhaseCommit(true);
@@ -1012,7 +1012,7 @@ public final class GridDhtColocatedLockFuture<K, V> 
extends GridCompoundIdentity
                 for (K key : distributedKeys)
                     tx.addKeyMapping(cctx.txKey(key), cctx.localNode());
 
-                if (tx.implicit() && !cctx.isStoreEnabled())
+                if (tx.implicit() && !cctx.writeThrough())
                     tx.onePhaseCommit(true);
             }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/atomic/GridLocalAtomicCache.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/atomic/GridLocalAtomicCache.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/atomic/GridLocalAtomicCache.java
index 4312c81..a488d3c 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/atomic/GridLocalAtomicCache.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/atomic/GridLocalAtomicCache.java
@@ -121,7 +121,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
             true,
             false,
             filter,
-            ctx.isStoreEnabled());
+            ctx.writeThrough());
     }
 
     /** {@inheritDoc} */
@@ -143,7 +143,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
             false,
             false,
             filter,
-            ctx.isStoreEnabled());
+            ctx.writeThrough());
     }
 
     /** {@inheritDoc} */
@@ -162,7 +162,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
             false,
             false,
             filter,
-            ctx.isStoreEnabled());
+            ctx.writeThrough());
     }
 
     /** {@inheritDoc} */
@@ -270,7 +270,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
             true,
             true,
             ctx.equalsPeekArray(oldVal),
-            ctx.isStoreEnabled());
+            ctx.writeThrough());
     }
 
     /** {@inheritDoc} */
@@ -288,7 +288,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
             true,
             true,
             ctx.equalsPeekArray(val),
-            ctx.isStoreEnabled());
+            ctx.writeThrough());
     }
 
     /** {@inheritDoc} */
@@ -329,7 +329,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
             false,
             false,
             filter,
-            ctx.isStoreEnabled());
+            ctx.writeThrough());
     }
 
     /** {@inheritDoc} */
@@ -360,7 +360,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
             true,
             false,
             filter,
-            ctx.isStoreEnabled());
+            ctx.writeThrough());
     }
 
     /** {@inheritDoc} */
@@ -387,7 +387,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
             false,
             false,
             filter,
-            ctx.isStoreEnabled());
+            ctx.writeThrough());
     }
 
     /** {@inheritDoc} */
@@ -415,7 +415,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
             false,
             false,
             filter,
-            ctx.isStoreEnabled());
+            ctx.writeThrough());
     }
 
     /** {@inheritDoc} */
@@ -444,7 +444,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
             false,
             false,
             ctx.equalsPeekArray(val),
-            ctx.isStoreEnabled());
+            ctx.writeThrough());
     }
 
     /** {@inheritDoc} */
@@ -475,7 +475,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
         Map<K, V> m = getAllInternal(Collections.singleton(key),
             filter != null ? new IgnitePredicate[]{filter} : null,
             ctx.isSwapOrOffheapEnabled(),
-            ctx.isStoreEnabled(),
+            ctx.readThrough(),
             ctx.hasFlag(CLONE),
             taskName,
             deserializePortable);
@@ -495,7 +495,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
         return getAllInternal(keys,
             filter != null ? new IgnitePredicate[]{filter} : null,
             ctx.isSwapOrOffheapEnabled(),
-            ctx.isStoreEnabled(),
+            ctx.readThrough(),
             ctx.hasFlag(CLONE),
             taskName,
             deserializePortable);
@@ -517,7 +517,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
         ctx.denyOnFlag(LOCAL);
 
         final boolean swapOrOffheap = ctx.isSwapOrOffheapEnabled();
-        final boolean storeEnabled = ctx.isStoreEnabled();
+        final boolean storeEnabled = ctx.readThrough();
         final boolean clone = ctx.hasFlag(CLONE);
 
         return asyncOp(new Callable<Map<K, V>>() {
@@ -774,7 +774,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
 
         final Collection<?> vals = map != null ? map.values() : invokeMap != 
null ? invokeMap.values() : null;
 
-        final boolean storeEnabled = ctx.isStoreEnabled();
+        final boolean writeThrough = ctx.writeThrough();
 
         final ExpiryPolicy expiry = expiryPerCall();
 
@@ -788,7 +788,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
                     retval,
                     rawRetval,
                     filter,
-                    storeEnabled);
+                    writeThrough);
             }
         });
     }
@@ -808,7 +808,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
         final boolean rawRetval,
         @Nullable final IgnitePredicate<GridCacheEntry<K, V>>[] filter
     ) {
-        final boolean storeEnabled = ctx.isStoreEnabled();
+        final boolean writeThrough = ctx.writeThrough();
 
         final ExpiryPolicy expiryPlc = expiryPerCall();
 
@@ -822,7 +822,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
                     retval,
                     rawRetval,
                     filter,
-                    storeEnabled);
+                    writeThrough);
             }
         });
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceIoc.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceIoc.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceIoc.java
index d142648..4232cbb 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceIoc.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceIoc.java
@@ -99,8 +99,10 @@ class GridResourceIoc {
      * @param dep Deployment.
      * @param depCls Deployment class.
      * @throws IgniteCheckedException Thrown in case of any errors during 
injection.
+     * @return {@code True} if resource was injected.
      */
-    void inject(Object target, Class<? extends Annotation> annCls, 
GridResourceInjector injector,
+    @SuppressWarnings("SimplifiableIfStatement")
+    boolean inject(Object target, Class<? extends Annotation> annCls, 
GridResourceInjector injector,
         @Nullable GridDeployment dep, @Nullable Class<?> depCls) throws 
IgniteCheckedException {
         assert target != null;
         assert annCls != null;
@@ -108,7 +110,9 @@ class GridResourceIoc {
 
         if (isAnnotationPresent(target, annCls, dep))
             // Use identity hash set to compare via referential equality.
-            injectInternal(target, annCls, injector, dep, depCls, new 
GridIdentityHashSet<>(3));
+            return injectInternal(target, annCls, injector, dep, depCls, new 
GridIdentityHashSet<>(3));
+
+        return false;
     }
 
     /**
@@ -119,8 +123,9 @@ class GridResourceIoc {
      * @param depCls Deployment class.
      * @param checkedObjs Set of already inspected objects to avoid indefinite 
recursion.
      * @throws IgniteCheckedException Thrown in case of any errors during 
injection.
+     * @return {@code True} if resource was injected.
      */
-    private void injectInternal(Object target, Class<? extends Annotation> 
annCls, GridResourceInjector injector,
+    private boolean injectInternal(Object target, Class<? extends Annotation> 
annCls, GridResourceInjector injector,
         @Nullable GridDeployment dep, @Nullable Class<?> depCls, Set<Object> 
checkedObjs) throws IgniteCheckedException {
         assert target != null;
         assert annCls != null;
@@ -133,16 +138,18 @@ class GridResourceIoc {
 
         // Skip this class if it does not need to be injected.
         if (skipClss != null && skipClss.contains(targetCls))
-            return;
+            return false;
 
         // Check if already inspected to avoid indefinite recursion.
         if (checkedObjs.contains(target))
-            return;
+            return false;
 
         checkedObjs.add(target);
 
         int annCnt = 0;
 
+        boolean injected = false;
+
         for (GridResourceField field : getFieldsWithAnnotation(dep, targetCls, 
annCls)) {
             Field f = field.getField();
 
@@ -152,24 +159,32 @@ class GridResourceIoc {
                 try {
                     Object obj = f.get(target);
 
-                    if (obj != null)
+                    if (obj != null) {
                         // Recursion.
-                        injectInternal(obj, annCls, injector, dep, depCls, 
checkedObjs);
+                        boolean injected0 = injectInternal(obj, annCls, 
injector, dep, depCls, checkedObjs);
+
+                        injected |= injected0;
+                    }
                 }
                 catch (IllegalAccessException e) {
                     throw new IgniteCheckedException("Failed to inject 
resource [field=" + f.getName() +
                         ", target=" + target + ']', e);
                 }
             }
-            else
+            else {
                 injector.inject(field, target, depCls, dep);
 
+                injected = true;
+            }
+
             annCnt++;
         }
 
         for (GridResourceMethod mtd : getMethodsWithAnnotation(dep, targetCls, 
annCls)) {
             injector.inject(mtd, target, depCls, dep);
 
+            injected = true;
+
             annCnt++;
         }
 
@@ -181,6 +196,8 @@ class GridResourceIoc {
 
             skipClss.add(targetCls);
         }
+
+        return injected;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceProcessor.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceProcessor.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceProcessor.java
index 998fb8f..6299569 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceProcessor.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceProcessor.java
@@ -18,6 +18,7 @@
 package org.gridgain.grid.kernal.processors.resource;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
 import org.apache.ignite.compute.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.lifecycle.*;
@@ -282,6 +283,25 @@ public class GridResourceProcessor extends 
GridProcessorAdapter {
     }
 
     /**
+     * Injects cache store session into given object.
+     *
+     * @param obj Object.
+     * @param ses Session to inject.
+     * @throws IgniteCheckedException If failed to inject.
+     */
+    public boolean injectStoreSession(Object obj, CacheStoreSession ses) 
throws IgniteCheckedException {
+        assert obj != null;
+
+        if (log.isDebugEnabled())
+            log.debug("Injecting cache store session: " + ses);
+
+        // Unwrap Proxy object.
+        obj = unwrapTarget(obj);
+
+        return ioc.inject(obj, IgniteCacheSessionResource.class, new 
GridResourceBasicInjector<>(ses), null, null);
+    }
+
+    /**
      * @param obj Object to inject.
      * @throws IgniteCheckedException If failed to inject.
      */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java
index 52b129b..05ec90b 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java
@@ -30,6 +30,7 @@ import org.gridgain.grid.util.typedef.internal.*;
 import org.gridgain.testframework.junits.common.*;
 import org.jdk8.backport.*;
 
+import javax.cache.configuration.*;
 import java.lang.reflect.*;
 import java.util.*;
 import java.util.concurrent.*;
@@ -82,6 +83,7 @@ public class GridCacheJdbcBlobStoreMultithreadedSelfTest 
extends GridCommonAbstr
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
     @Override protected final IgniteConfiguration getConfiguration(String 
gridName) throws Exception {
         IgniteConfiguration c = super.getConfiguration(gridName);
 
@@ -100,7 +102,9 @@ public class GridCacheJdbcBlobStoreMultithreadedSelfTest 
extends GridCommonAbstr
         cc.setBackups(1);
         cc.setDistributionMode(mode);
 
-        cc.setStore(store);
+        cc.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store));
+        cc.setReadThrough(true);
+        cc.setWriteThrough(true);
 
         c.setCacheConfiguration(cc);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java
index 0459707..9b14223 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java
@@ -120,7 +120,14 @@ public abstract class IgniteCacheAbstractTest extends 
GridCommonAbstractTest {
 
         cfg.setCacheWriterFactory(writerFactory());
 
-        cfg.setStore(cacheStore());
+        CacheStore<?, ?> store = cacheStore();
+
+        if (store != null) {
+            cfg.setCacheStoreFactory(new 
FactoryBuilder.SingletonFactory(store));
+
+            cfg.setReadThrough(true);
+            cfg.setWriteThrough(true);
+        }
 
         if (cacheMode() == PARTITIONED)
             cfg.setBackups(1);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java
index 9f03e96..3a761f8 100644
--- 
a/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java
+++ 
b/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java
@@ -24,6 +24,7 @@ import org.gridgain.grid.kernal.processors.cache.*;
 import org.gridgain.grid.util.typedef.*;
 import org.jetbrains.annotations.*;
 
+import javax.cache.configuration.*;
 import java.util.*;
 
 /**
@@ -42,10 +43,13 @@ public class GridCacheLoadOnlyStoreAdapterSelfTest extends 
GridCacheAbstractSelf
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
     @Override protected CacheConfiguration cacheConfiguration(String gridName) 
throws Exception {
         CacheConfiguration cfg = super.cacheConfiguration(gridName);
 
-        cfg.setStore(new TestStore());
+        cfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(new 
TestStore()));
+        cfg.setReadThrough(true);
+        cfg.setWriteThrough(true);
 
         return cfg;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractSelfTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractSelfTest.java
index 2552783..e534c1a 100644
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractSelfTest.java
+++ 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractSelfTest.java
@@ -39,6 +39,7 @@ import org.jdk8.backport.*;
 import org.jetbrains.annotations.*;
 
 import javax.cache.*;
+import javax.cache.configuration.*;
 import java.util.*;
 import java.util.concurrent.atomic.*;
 
@@ -228,10 +229,19 @@ public abstract class GridCacheAbstractSelfTest extends 
GridCommonAbstractTest {
      * @return Cache configuration.
      * @throws Exception In case of error.
      */
+    @SuppressWarnings("unchecked")
     protected CacheConfiguration cacheConfiguration(String gridName) throws 
Exception {
         CacheConfiguration cfg = defaultCacheConfiguration();
 
-        cfg.setStore(cacheStore());
+        CacheStore<?, ?> store = cacheStore();
+
+        if (store != null) {
+            cfg.setCacheStoreFactory(new 
FactoryBuilder.SingletonFactory(store));
+
+            cfg.setReadThrough(true);
+            cfg.setWriteThrough(true);
+        }
+
         cfg.setSwapEnabled(swapEnabled());
         cfg.setCacheMode(cacheMode());
         cfg.setAtomicityMode(atomicityMode());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractTxReadTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractTxReadTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractTxReadTest.java
index 10e30bb..b9a81ca 100644
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractTxReadTest.java
+++ 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractTxReadTest.java
@@ -45,7 +45,7 @@ public abstract class GridCacheAbstractTxReadTest extends 
GridCacheAbstractSelfT
 
         cfg.setWriteSynchronizationMode(FULL_SYNC);
 
-        cfg.setStore(null);
+        cfg.setCacheStoreFactory(null);
 
         return cfg;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreAbstractTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreAbstractTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreAbstractTest.java
index 3af2b9c..0bb03b8 100644
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreAbstractTest.java
+++ 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreAbstractTest.java
@@ -19,6 +19,7 @@ package org.gridgain.grid.kernal.processors.cache;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.store.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
@@ -29,6 +30,7 @@ import org.gridgain.grid.util.typedef.*;
 import org.gridgain.testframework.junits.common.*;
 import org.jetbrains.annotations.*;
 
+import javax.cache.configuration.*;
 import java.util.*;
 
 import static org.gridgain.grid.cache.GridCacheAtomicityMode.*;
@@ -71,6 +73,7 @@ public abstract class GridCacheBasicStoreAbstractTest extends 
GridCommonAbstract
     protected abstract GridCacheMode cacheMode();
 
     /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
     @Override protected final IgniteConfiguration getConfiguration(String 
gridName) throws Exception {
         IgniteConfiguration c = super.getConfiguration(gridName);
 
@@ -89,7 +92,9 @@ public abstract class GridCacheBasicStoreAbstractTest extends 
GridCommonAbstract
         cc.setDistributionMode(distributionMode());
         cc.setPreloadMode(SYNC);
 
-        cc.setStore(store);
+        cc.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store));
+        cc.setReadThrough(true);
+        cc.setWriteThrough(true);
 
         c.setCacheConfiguration(cc);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreMultithreadedAbstractTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreMultithreadedAbstractTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreMultithreadedAbstractTest.java
index a5ac312..bd8e8ed 100644
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreMultithreadedAbstractTest.java
+++ 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreMultithreadedAbstractTest.java
@@ -26,6 +26,7 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 import org.gridgain.testframework.junits.common.*;
 
 import javax.cache.*;
+import javax.cache.configuration.*;
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.*;
 
@@ -61,6 +62,7 @@ public abstract class 
GridCacheBasicStoreMultithreadedAbstractTest extends GridC
     protected abstract GridCacheMode cacheMode();
 
     /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
     @Override protected final IgniteConfiguration getConfiguration(String 
gridName) throws Exception {
         IgniteConfiguration c = super.getConfiguration(gridName);
 
@@ -76,7 +78,9 @@ public abstract class 
GridCacheBasicStoreMultithreadedAbstractTest extends GridC
         cc.setWriteSynchronizationMode(FULL_SYNC);
         cc.setSwapEnabled(false);
 
-        cc.setStore(store);
+        cc.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store));
+        cc.setReadThrough(true);
+        cc.setWriteThrough(true);
 
         c.setCacheConfiguration(cc);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
index 77de2ce..aaff1c5 100644
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
+++ 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
@@ -42,6 +42,7 @@ import org.gridgain.testframework.junits.common.*;
 import org.jetbrains.annotations.*;
 
 import javax.cache.*;
+import javax.cache.configuration.*;
 import javax.cache.integration.*;
 import java.util.*;
 import java.util.concurrent.*;
@@ -736,10 +737,18 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
 
         initCache = new C1<CacheConfiguration, Void>() {
             /** {@inheritDoc} */
+            @SuppressWarnings("unchecked")
             @Override public Void apply(CacheConfiguration cfg) {
                 cfg.setAffinity(new GridCacheConsistentHashAffinityFunction() 
{/*No-op.*/});
+
                 cfg.setEvictionPolicy(new GridCacheFifoEvictionPolicy());
-                cfg.setStore(new TestStore());
+
+                cfg.setCacheStoreFactory(new 
FactoryBuilder.SingletonFactory(new TestStore()));
+
+                cfg.setReadThrough(true);
+
+                cfg.setWriteThrough(true);
+
                 return null;
             }
         };
@@ -750,8 +759,11 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
             /** {@inheritDoc} */
             @Override public Void apply(CacheConfiguration cfg) {
                 cfg.setAffinity(new GridCacheConsistentHashAffinityFunction());
+
                 cfg.setEvictionPolicy(new GridCacheLruEvictionPolicy());
-                cfg.setStore(null);
+
+                cfg.setCacheStoreFactory(null);
+
                 return null;
             }
         };
@@ -768,10 +780,15 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
         cacheMode = PARTITIONED;
 
         initCache = new C1<CacheConfiguration, Void>() {
+            @SuppressWarnings("unchecked")
             @Override public Void apply(CacheConfiguration cc) {
                 cc.setAtomicityMode(ATOMIC);
+
                 cc.setDistributionMode(PARTITIONED_ONLY);
-                cc.setStore(new TestStore());
+
+                cc.setCacheStoreFactory(new 
FactoryBuilder.SingletonFactory(new TestStore()));
+                cc.setReadThrough(true);
+                cc.setWriteThrough(true);
 
                 return null;
             }
@@ -783,7 +800,7 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
             @Override public Void apply(CacheConfiguration cc) {
                 cc.setAtomicityMode(ATOMIC);
                 cc.setDistributionMode(CLIENT_ONLY);
-                cc.setStore(null);
+                cc.setCacheStoreFactory(null);
 
                 return null;
             }
@@ -801,10 +818,17 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
         cacheMode = PARTITIONED;
 
         initCache = new C1<CacheConfiguration, Void>() {
+            @SuppressWarnings("unchecked")
             @Override public Void apply(CacheConfiguration cc) {
                 cc.setAtomicityMode(ATOMIC);
+
                 cc.setDistributionMode(PARTITIONED_ONLY);
-                cc.setStore(new TestStore());
+
+                cc.setCacheStoreFactory(new 
FactoryBuilder.SingletonFactory(new TestStore()));
+
+                cc.setReadThrough(true);
+
+                cc.setWriteThrough(true);
 
                 return null;
             }
@@ -816,7 +840,7 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
             @Override public Void apply(CacheConfiguration cc) {
                 cc.setAtomicityMode(ATOMIC);
                 cc.setDistributionMode(PARTITIONED_ONLY);
-                cc.setStore(null);
+                cc.setCacheStoreFactory(null);
 
                 return null;
             }
@@ -840,10 +864,15 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
         cacheMode = PARTITIONED;
 
         initCache = new C1<CacheConfiguration, Void>() {
+            @SuppressWarnings("unchecked")
             @Override public Void apply(CacheConfiguration cc) {
                 cc.setAtomicityMode(TRANSACTIONAL);
+
                 cc.setDistributionMode(PARTITIONED_ONLY);
-                cc.setStore(new TestStore());
+
+                cc.setCacheStoreFactory(new 
FactoryBuilder.SingletonFactory(new TestStore()));
+                cc.setReadThrough(true);
+                cc.setWriteThrough(true);
 
                 return null;
             }
@@ -854,8 +883,10 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
         initCache = new C1<CacheConfiguration, Void>() {
             @Override public Void apply(CacheConfiguration cc) {
                 cc.setAtomicityMode(TRANSACTIONAL);
+
                 cc.setDistributionMode(PARTITIONED_ONLY);
-                cc.setStore(null);
+
+                cc.setCacheStoreFactory(null);
 
                 return null;
             }
@@ -879,10 +910,15 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
         cacheMode = PARTITIONED;
 
         initCache = new C1<CacheConfiguration, Void>() {
+            @SuppressWarnings("unchecked")
             @Override public Void apply(CacheConfiguration cc) {
                 cc.setAtomicityMode(TRANSACTIONAL);
+
                 cc.setDistributionMode(PARTITIONED_ONLY);
-                cc.setStore(new TestStore());
+
+                cc.setCacheStoreFactory(new 
FactoryBuilder.SingletonFactory(new TestStore()));
+                cc.setReadThrough(true);
+                cc.setWriteThrough(true);
 
                 return null;
             }
@@ -893,8 +929,10 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
         initCache = new C1<CacheConfiguration, Void>() {
             @Override public Void apply(CacheConfiguration cc) {
                 cc.setAtomicityMode(TRANSACTIONAL);
+
                 cc.setDistributionMode(CLIENT_ONLY);
-                cc.setStore(null);
+
+                cc.setCacheStoreFactory(null);
 
                 return null;
             }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheGetAndTransformStoreAbstractTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheGetAndTransformStoreAbstractTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheGetAndTransformStoreAbstractTest.java
index e116448..0f2de67 100644
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheGetAndTransformStoreAbstractTest.java
+++ 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheGetAndTransformStoreAbstractTest.java
@@ -19,6 +19,7 @@ package org.gridgain.grid.kernal.processors.cache;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.store.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.lang.*;
 import org.gridgain.grid.cache.*;
@@ -27,6 +28,7 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 import org.gridgain.testframework.junits.common.*;
 
+import javax.cache.configuration.*;
 import javax.cache.processor.*;
 import java.io.*;
 import java.util.concurrent.*;
@@ -70,6 +72,7 @@ public abstract class 
GridCacheGetAndTransformStoreAbstractTest extends GridComm
     protected abstract GridCacheMode cacheMode();
 
     /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
     @Override protected final IgniteConfiguration getConfiguration(String 
gridName) throws Exception {
         IgniteConfiguration c = super.getConfiguration(gridName);
 
@@ -88,7 +91,9 @@ public abstract class 
GridCacheGetAndTransformStoreAbstractTest extends GridComm
         cc.setDistributionMode(distributionMode());
         cc.setPreloadMode(SYNC);
 
-        cc.setStore(store);
+        cc.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store));
+        cc.setReadThrough(true);
+        cc.setWriteThrough(true);
 
         c.setCacheConfiguration(cc);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
index f230191..9e8f421 100644
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
+++ 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
@@ -26,6 +26,8 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 import org.gridgain.grid.cache.*;
 import org.gridgain.grid.cache.datastructures.*;
+import org.gridgain.grid.kernal.*;
+import org.gridgain.grid.kernal.processors.cache.*;
 import org.gridgain.testframework.junits.common.*;
 import org.mockito.*;
 
@@ -183,6 +185,8 @@ public abstract class 
GridCacheAtomicReferenceApiSelfAbstractTest extends GridCo
 
         cache.dataStructures().removeAtomicReference(atomicName);
 
-        Mockito.verifyZeroInteractions(cache.configuration().getStore()); // 
Store shouldn't be ever called.
+        GridCacheContext ctx = 
((GridKernal)grid()).context().cache().internalCache().context();
+
+        Mockito.verifyZeroInteractions(ctx.store().configuredStore()); // 
Store shouldn't be ever called.
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java
index 31ddb43..ace6c4a 100644
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java
+++ 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java
@@ -762,7 +762,11 @@ public class GridCacheColocatedDebugTest extends 
GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     private void checkStore(Ignite ignite, Map<Integer, String> map) throws 
Exception {
-        CacheStore store = 
ignite.configuration().getCacheConfiguration()[0].getStore();
+        String cacheName = 
ignite.configuration().getCacheConfiguration()[0].getName();
+
+        GridCacheContext ctx = 
((GridKernal)grid()).context().cache().internalCache(cacheName).context();
+
+        CacheStore store = ctx.store().configuredStore();
 
         assertEquals(map, ((GridCacheTestStore)store).getMap());
     }
@@ -774,7 +778,11 @@ public class GridCacheColocatedDebugTest extends 
GridCommonAbstractTest {
      */
     private void clearStores(int cnt) {
         for (int i = 0; i < cnt; i++) {
-            CacheStore store = 
grid(i).configuration().getCacheConfiguration()[0].getStore();
+            String cacheName = 
grid(i).configuration().getCacheConfiguration()[0].getName();
+
+            GridCacheContext ctx = 
((GridKernal)grid()).context().cache().internalCache(cacheName).context();
+
+            CacheStore store = ctx.store().configuredStore();
 
             ((GridCacheTestStore)store).reset();
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5521dac5/modules/core/src/test/java/org/gridgain/loadtests/hashmap/GridCacheTestContext.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/loadtests/hashmap/GridCacheTestContext.java
 
b/modules/core/src/test/java/org/gridgain/loadtests/hashmap/GridCacheTestContext.java
index a0ee967..a808118 100644
--- 
a/modules/core/src/test/java/org/gridgain/loadtests/hashmap/GridCacheTestContext.java
+++ 
b/modules/core/src/test/java/org/gridgain/loadtests/hashmap/GridCacheTestContext.java
@@ -17,6 +17,7 @@
 
 package org.gridgain.loadtests.hashmap;
 
+import org.apache.ignite.cache.*;
 import org.gridgain.grid.kernal.processors.cache.*;
 import org.gridgain.grid.kernal.processors.cache.datastructures.*;
 import org.gridgain.grid.kernal.processors.cache.dr.os.*;
@@ -52,7 +53,7 @@ public class GridCacheTestContext<K, V> extends 
GridCacheContext<K, V> {
             defaultCacheConfiguration(),
             new GridCacheEventManager<K, V>(),
             new GridCacheSwapManager<K, V>(false),
-            new GridCacheStoreManager<K, V>(null, null),
+            new GridCacheStoreManager<K, V>(null, null, new 
CacheConfiguration()),
             new GridCacheEvictionManager<K, V>(),
             new GridCacheLocalQueryManager<K, V>(),
             new GridCacheContinuousQueryManager<K, V>(),

Reply via email to