ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: ignite-114
Date Wed, 08 Jun 2016 11:49:51 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-114 e584a3a0c -> 84a9161e9


ignite-114


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

Branch: refs/heads/ignite-114
Commit: 84a9161e9d79239a419972f005c753210ae9f918
Parents: e584a3a
Author: sboikov <sboikov@gridgain.com>
Authored: Wed Jun 8 11:43:58 2016 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Wed Jun 8 14:45:04 2016 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheMapEntry.java     |   9 -
 .../processors/cache/GridCacheUtils.java        |   4 +-
 .../distributed/dht/GridDhtLockFuture.java      |   9 -
 .../distributed/dht/GridDhtTxPrepareFuture.java |  14 +-
 .../cache/transactions/IgniteTxEntry.java       |  14 +-
 .../cache/transactions/IgniteTxHandler.java     |  14 +
 .../transactions/IgniteTxLocalAdapter.java      |  10 +-
 ...gniteCacheInvokeReadThroughAbstractTest.java |  10 +-
 ...iteCacheInvokeReadThroughSingleNodeTest.java |  32 ++-
 .../cache/IgniteCacheInvokeReadThroughTest.java |  92 +++++-
 .../IgniteCacheReadThroughStoreCallTest.java    | 288 +++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite4.java       |   2 +
 12 files changed, 434 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/84a9161e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index be800ff..b5359f3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -1002,15 +1002,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter
impleme
 
                     if (cctx.deferredDelete() && deletedUnlocked() && !isInternal()
&& !detached())
                         deletedUnlocked(false);
-
-                    if (tx != null) {
-                        IgniteTxEntry e = tx.entry(cctx.txKey(key));
-
-                        assert e != null : this;
-
-                        if (e != null)
-                            e.valueReadFromStore(true);
-                    }
                 }
 
                 if (evt && cctx.events().isRecordable(EVT_CACHE_OBJECT_READ))

http://git-wip-us.apache.org/repos/asf/ignite/blob/84a9161e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index ed63f91..87c4a3a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -155,8 +155,8 @@ public class GridCacheUtils {
     /** Keep serialized flag. */
     public static final int KEEP_BINARY_FLAG_MASK = 0x2;
 
-    /** Read from store flag. */
-    public static final int READ_FROM_STORE_FLAG_MASK = 0x4;
+    /** Flag indicating that old value for 'invoke' operation was non null on primary node.
*/
+    public static final int OLD_VAL_ON_PRIMARY = 0x4;
 
     /** Empty predicate array. */
     private static final IgnitePredicate[] EMPTY = new IgnitePredicate[0];

http://git-wip-us.apache.org/repos/asf/ignite/blob/84a9161e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
index 0cccc2b..0a3513a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
@@ -1061,15 +1061,6 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
                                     topVer,
                                     GridDrType.DR_LOAD,
                                     true);
-
-                                if (inTx()) {
-                                    IgniteTxEntry txEntry = tx.entry(cctx.txKey(key));
-
-                                    assert txEntry != null : key;
-
-                                    if (txEntry != null)
-                                        txEntry.valueReadFromStore(true);
-                                }
                             }
                             catch (GridCacheEntryRemovedException e) {
                                 assert false : "Should not get removed exception while holding
lock on entry " +

http://git-wip-us.apache.org/repos/asf/ignite/blob/84a9161e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index 6b9ab6a..cedfee5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -373,6 +373,8 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
 
                             boolean modified = false;
 
+                            txEntry.oldValueOnPrimary(val != null);
+
                             for (T2<EntryProcessor<Object, Object, Object>, Object[]>
t : txEntry.entryProcessors()) {
                                  CacheInvokeEntry<Object, Object> invokeEntry = new
CacheInvokeEntry<>(key, val,
                                      txEntry.cached().version(), keepBinary, txEntry.cached());
@@ -1324,16 +1326,10 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
                 GridDistributedTxMapping global = globalMap.get(n.id());
 
                 if (!F.isEmpty(entry.entryProcessors())) {
-                    boolean sndVal = entry.valueReadFromStore();
-
-                    if (!sndVal) {
-                        GridDhtPartitionState state = entry.context().topology().partitionState(n.id(),
-                            entry.cached().partition());
-
-                        sndVal = state != GridDhtPartitionState.OWNING && state !=
GridDhtPartitionState.EVICTED;
-                    }
+                    GridDhtPartitionState state = entry.context().topology().partitionState(n.id(),
+                        entry.cached().partition());
 
-                    if (sndVal) {
+                    if (state != GridDhtPartitionState.OWNING && state != GridDhtPartitionState.EVICTED)
{
                         T2<GridCacheOperation, CacheObject> procVal = entry.entryProcessorCalculatedValue();
 
                         assert procVal != null : entry;

http://git-wip-us.apache.org/repos/asf/ignite/blob/84a9161e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
index 037eca2..3258ce9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
@@ -58,7 +58,7 @@ import org.jetbrains.annotations.Nullable;
 import static org.apache.ignite.internal.processors.cache.GridCacheOperation.READ;
 import static org.apache.ignite.internal.processors.cache.GridCacheOperation.TRANSFORM;
 import static org.apache.ignite.internal.processors.cache.GridCacheUtils.KEEP_BINARY_FLAG_MASK;
-import static org.apache.ignite.internal.processors.cache.GridCacheUtils.READ_FROM_STORE_FLAG_MASK;
+import static org.apache.ignite.internal.processors.cache.GridCacheUtils.OLD_VAL_ON_PRIMARY;
 import static org.apache.ignite.internal.processors.cache.GridCacheUtils.SKIP_STORE_FLAG_MASK;
 
 /**
@@ -487,17 +487,17 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
     }
 
     /**
-     * @param readFromStore Flag indicating whether entry value was read from store.
+     * @param oldValOnPrimary {@code True} If old value for 'invoke' operation was non null
on primary node.
      */
-    public void valueReadFromStore(boolean readFromStore) {
-        setFlag(readFromStore, READ_FROM_STORE_FLAG_MASK);
+    public void oldValueOnPrimary(boolean oldValOnPrimary) {
+        setFlag(oldValOnPrimary, OLD_VAL_ON_PRIMARY);
     }
 
     /**
-     * @return Flag indicating whether entry value was read from store.
+     * @return {@code True} If old value for 'invoke' operation was non null on primary node.
      */
-    public boolean valueReadFromStore() {
-        return isFlag(READ_FROM_STORE_FLAG_MASK);
+    public boolean oldValueOnPrimary() {
+        return isFlag(OLD_VAL_ON_PRIMARY);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/84a9161e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
index b25baf8..e6cece4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
@@ -25,9 +25,11 @@ import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
 import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo;
+import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
 import org.apache.ignite.internal.processors.cache.GridCacheMessage;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
@@ -73,6 +75,7 @@ import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL;
 import static org.apache.ignite.internal.managers.communication.GridIoPolicy.UTILITY_CACHE_POOL;
+import static org.apache.ignite.internal.processors.cache.GridCacheOperation.*;
 import static org.apache.ignite.internal.processors.cache.GridCacheUtils.isNearEnabled;
 import static org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishFuture.FINISH_NEAR_ONE_PHASE_SINCE;
 import static org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx.FinalizationStatus.USER_FINISH;
@@ -1165,6 +1168,17 @@ public class IgniteTxHandler {
                             if (info != null && !info.isNew() && !info.isDeleted())
                                 res.addPreloadEntry(info);
                         }
+
+                        if (cacheCtx.readThroughConfigured() &&
+                            !entry.skipStore() &&
+                            entry.op() == TRANSFORM &&
+                            entry.oldValueOnPrimary() &&
+                            !entry.hasValue()) {
+                            CacheObject cacheObj = cacheCtx.toCacheObject(cacheCtx.store().load(null,
entry.key()));
+
+                            if (cacheObj != null)
+                                entry.readValue(cacheObj);
+                        }
                     }
                     catch (GridDhtInvalidPartitionException e) {
                         tx.addInvalidPartition(cacheCtx, e.partition());

http://git-wip-us.apache.org/repos/asf/ignite/blob/84a9161e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index eacf974..f1a2bc0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -2646,8 +2646,10 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                     if (retval || invoke) {
                         if (!cacheCtx.isNear()) {
                             if (!hasPrevVal) {
-                                boolean readThrough =
-                                    (invoke || cacheCtx.loadPreviousValue()) && !txEntry.skipStore();
+                                // For non-local cache should read from store after lock
on primary.
+                                boolean readThrough = cacheCtx.isLocal() &&
+                                    (invoke || cacheCtx.loadPreviousValue()) &&
+                                    !txEntry.skipStore();
 
                                 v = cached.innerGet(
                                     null,
@@ -2881,7 +2883,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                 IgniteInternalFuture<Boolean> fut = cacheCtx.cache().txLockAsync(enlisted,
                     timeout,
                     this,
-                    entryProcessor != null, // Needed to force load from store.
+                    /*read*/entryProcessor != null, // Needed to force load from store.
                     retval,
                     isolation,
                     isInvalidate(),
@@ -3061,7 +3063,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                 IgniteInternalFuture<Boolean> fut = cacheCtx.cache().txLockAsync(enlisted,
                     timeout,
                     this,
-                    invokeMap != null, // Needed to force load from store.
+                    /*read*/invokeMap != null, // Needed to force load from store.
                     retval,
                     isolation,
                     isInvalidate(),

http://git-wip-us.apache.org/repos/asf/ignite/blob/84a9161e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughAbstractTest.java
index fb6c5c3..294ebea 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughAbstractTest.java
@@ -28,6 +28,7 @@ import javax.cache.processor.MutableEntry;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMemoryMode;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
 import org.apache.ignite.cache.store.CacheStore;
@@ -161,9 +162,6 @@ public abstract class IgniteCacheInvokeReadThroughAbstractTest extends
GridCommo
                 if (ccfg.getAtomicityMode() == TRANSACTIONAL) {
                     for (TransactionConcurrency concurrency : TransactionConcurrency.values())
{
                         for (TransactionIsolation isolation : TransactionIsolation.values())
{
-                            if (concurrency == TransactionConcurrency.OPTIMISTIC)
-                                continue;
-
                             log.info("Test tx [concurrency=" + concurrency + ", isolation="
+ isolation + ']');
 
                             for (int i = 0; i < 50; i++)
@@ -187,9 +185,6 @@ public abstract class IgniteCacheInvokeReadThroughAbstractTest extends
GridCommo
 
                     for (TransactionConcurrency concurrency : TransactionConcurrency.values())
{
                         for (TransactionIsolation isolation : TransactionIsolation.values())
{
-                            if (concurrency == TransactionConcurrency.OPTIMISTIC || isolation
== TransactionIsolation.READ_COMMITTED)
-                                continue;
-
                             log.info("Test tx2 [concurrency=" + concurrency + ", isolation="
+ isolation + ']');
 
                             for (int i = 0; i < 50; i++)
@@ -327,6 +322,7 @@ public abstract class IgniteCacheInvokeReadThroughAbstractTest extends
GridCommo
     /**
      * @param cacheMode Cache mode.
      * @param atomicityMode Atomicity mode.
+     * @param memoryMode Memory mode.
      * @param backups Number of backups.
      * @param nearCache Near cache flag.
      * @return Cache configuration.
@@ -334,6 +330,7 @@ public abstract class IgniteCacheInvokeReadThroughAbstractTest extends
GridCommo
     @SuppressWarnings("unchecked")
     protected CacheConfiguration cacheConfiguration(CacheMode cacheMode,
         CacheAtomicityMode atomicityMode,
+        CacheMemoryMode memoryMode,
         int backups,
         boolean nearCache) {
         CacheConfiguration ccfg = new CacheConfiguration();
@@ -346,6 +343,7 @@ public abstract class IgniteCacheInvokeReadThroughAbstractTest extends
GridCommo
         ccfg.setCacheMode(cacheMode);
         ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
         ccfg.setAtomicWriteOrderMode(PRIMARY);
+        ccfg.setMemoryMode(memoryMode);
 
         if (nearCache)
             ccfg.setNearConfiguration(new NearCacheConfiguration());

http://git-wip-us.apache.org/repos/asf/ignite/blob/84a9161e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughSingleNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughSingleNodeTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughSingleNodeTest.java
index 406e5af..b451abf 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughSingleNodeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughSingleNodeTest.java
@@ -19,6 +19,8 @@ package org.apache.ignite.internal.processors.cache;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
 import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED;
+import static org.apache.ignite.cache.CacheMemoryMode.ONHEAP_TIERED;
 import static org.apache.ignite.cache.CacheMode.LOCAL;
 import static org.apache.ignite.cache.CacheMode.PARTITIONED;
 import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -36,55 +38,69 @@ public class IgniteCacheInvokeReadThroughSingleNodeTest extends IgniteCacheInvok
      * @throws Exception If failed.
      */
     public void testInvokeReadThroughAtomic() throws Exception {
-        invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, 1, false));
+        invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, ONHEAP_TIERED, 1, false));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testInvokeReadThroughAtomic_Offheap() throws Exception {
+        invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, OFFHEAP_TIERED, 1, false));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testInvokeReadThroughAtomicNearCache() throws Exception {
-        invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, 1, true));
+        invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, ONHEAP_TIERED, 1, true));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testInvokeReadThroughAtomicReplicated() throws Exception {
-        invokeReadThrough(cacheConfiguration(REPLICATED, ATOMIC, 0, false));
+        invokeReadThrough(cacheConfiguration(REPLICATED, ATOMIC, ONHEAP_TIERED, 0, false));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testInvokeReadThroughAtomicLocal() throws Exception {
-        invokeReadThrough(cacheConfiguration(LOCAL, ATOMIC, 0, false));
+        invokeReadThrough(cacheConfiguration(LOCAL, ATOMIC, ONHEAP_TIERED, 0, false));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testInvokeReadThroughTx() throws Exception {
-        invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, 1, false));
+        invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, ONHEAP_TIERED, 1,
false));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testInvokeReadThroughTx_Offheap() throws Exception {
+        invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, OFFHEAP_TIERED,
1, false));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testInvokeReadThroughTxNearCache() throws Exception {
-        invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, 1, true));
+        invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, ONHEAP_TIERED, 1,
true));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testInvokeReadThroughTxReplicated() throws Exception {
-        invokeReadThrough(cacheConfiguration(REPLICATED, TRANSACTIONAL, 0, false));
+        invokeReadThrough(cacheConfiguration(REPLICATED, TRANSACTIONAL, ONHEAP_TIERED, 0,
false));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testInvokeReadThroughTxLocal() throws Exception {
-        invokeReadThrough(cacheConfiguration(LOCAL, TRANSACTIONAL, 0, false));
+        invokeReadThrough(cacheConfiguration(LOCAL, TRANSACTIONAL, ONHEAP_TIERED, 0, false));
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/84a9161e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughTest.java
index 8fd3758..9578227 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughTest.java
@@ -19,6 +19,8 @@ package org.apache.ignite.internal.processors.cache;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
 import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED;
+import static org.apache.ignite.cache.CacheMemoryMode.ONHEAP_TIERED;
 import static org.apache.ignite.cache.CacheMode.PARTITIONED;
 import static org.apache.ignite.cache.CacheMode.REPLICATED;
 
@@ -39,69 +41,139 @@ public class IgniteCacheInvokeReadThroughTest extends IgniteCacheInvokeReadThrou
      * @throws Exception If failed.
      */
     public void testInvokeReadThroughAtomic0() throws Exception {
-        invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, 0, false));
+        invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, ONHEAP_TIERED, 0, false));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testInvokeReadThroughAtomic1() throws Exception {
-        invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, 1, false));
+        invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, ONHEAP_TIERED, 1, false));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testInvokeReadThroughAtomic2() throws Exception {
-        invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, 2, false));
+        invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, ONHEAP_TIERED, 2, false));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testInvokeReadThroughAtomicNearCache() throws Exception {
-        invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, 1, true));
+        invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, ONHEAP_TIERED, 1, true));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testInvokeReadThroughAtomicReplicated() throws Exception {
-        invokeReadThrough(cacheConfiguration(REPLICATED, ATOMIC, 0, false));
+        invokeReadThrough(cacheConfiguration(REPLICATED, ATOMIC, ONHEAP_TIERED, 0, false));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testInvokeReadThroughAtomic0_Offheap() throws Exception {
+        invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, OFFHEAP_TIERED, 0, false));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testInvokeReadThroughAtomic1_Offheap() throws Exception {
+        invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, OFFHEAP_TIERED, 1, false));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testInvokeReadThroughAtomic2_Offheap() throws Exception {
+        invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, OFFHEAP_TIERED, 2, false));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testInvokeReadThroughAtomicNearCache_Offheap() throws Exception {
+        invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, OFFHEAP_TIERED, 1, true));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testInvokeReadThroughAtomicReplicated_Offheap() throws Exception {
+        invokeReadThrough(cacheConfiguration(REPLICATED, ATOMIC, OFFHEAP_TIERED, 0, false));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testInvokeReadThroughTx0() throws Exception {
-        invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, 0, false));
+        invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, ONHEAP_TIERED, 0,
false));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testInvokeReadThroughTx1() throws Exception {
-        invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, 1, false));
+        invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, ONHEAP_TIERED, 1,
false));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testInvokeReadThroughTx2() throws Exception {
-        invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, 2, false));
+        invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, ONHEAP_TIERED, 2,
false));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testInvokeReadThroughTxNearCache() throws Exception {
-        invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, 1, true));
+        invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, ONHEAP_TIERED, 1,
true));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testInvokeReadThroughTxReplicated() throws Exception {
-        invokeReadThrough(cacheConfiguration(REPLICATED, TRANSACTIONAL, 0, false));
+        invokeReadThrough(cacheConfiguration(REPLICATED, TRANSACTIONAL, ONHEAP_TIERED, 0,
false));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testInvokeReadThroughTx0_Offheap() throws Exception {
+        invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, OFFHEAP_TIERED,
0, false));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testInvokeReadThroughTx1_Offheap() throws Exception {
+        invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, OFFHEAP_TIERED,
1, false));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testInvokeReadThroughTx2_Offheap() throws Exception {
+        invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, OFFHEAP_TIERED,
2, false));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testInvokeReadThroughTxNearCache_Offheap() throws Exception {
+        invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, OFFHEAP_TIERED,
1, true));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testInvokeReadThroughTxReplicated_Offheap() throws Exception {
+        invokeReadThrough(cacheConfiguration(REPLICATED, TRANSACTIONAL, OFFHEAP_TIERED, 0,
false));
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/84a9161e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughStoreCallTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughStoreCallTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughStoreCallTest.java
new file mode 100644
index 0000000..bb092d4
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughStoreCallTest.java
@@ -0,0 +1,288 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.cache.Cache;
+import javax.cache.configuration.Factory;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.cache.store.CacheStore;
+import org.apache.ignite.cache.store.CacheStoreAdapter;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.lang.IgniteBiInClosure;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.jetbrains.annotations.Nullable;
+import org.jsr166.ConcurrentHashMap8;
+
+import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.PRIMARY;
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.transactions.TransactionIsolation.values;
+
+/**
+ *
+ */
+public class IgniteCacheReadThroughStoreCallTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private static final Map<Object, Object> storeMap = new ConcurrentHashMap8<>();
+
+    /** */
+    protected boolean client;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+        cfg.setClientMode(client);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+
+        storeMap.clear();
+
+        super.afterTest();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testMultiNode() throws Exception {
+        startGridsMultiThreaded(4);
+
+        client = true;
+
+        startGrid(4);
+
+        checkLoadCount(cacheConfiguration(PARTITIONED, ATOMIC, 0));
+
+        checkLoadCount(cacheConfiguration(PARTITIONED, ATOMIC, 1));
+
+        checkLoadCount(cacheConfiguration(PARTITIONED, ATOMIC, 2));
+
+        checkLoadCount(cacheConfiguration(PARTITIONED, TRANSACTIONAL, 0));
+
+        checkLoadCount(cacheConfiguration(PARTITIONED, TRANSACTIONAL, 1));
+
+        checkLoadCount(cacheConfiguration(PARTITIONED, TRANSACTIONAL, 2));
+    }
+
+    /**
+     * @param ccfg Cache configuration.
+     * @throws Exception If failed.
+     */
+    private void checkLoadCount(CacheConfiguration<Object, Object> ccfg) throws Exception
{
+        storeMap.clear();
+
+        Ignite ignite0 = ignite(0);
+
+        ignite0.createCache(ccfg);
+
+        try {
+            int key = 0;
+
+            for (Ignite node : G.allGrids()) {
+                log.info("Test for node: " + node.name());
+
+                final IgniteCache<Object, Object> cache = node.cache(ccfg.getName());
+
+                for (int i = 0; i < 50; i++) {
+                    final int k = key++;
+
+                    checkReadThrough(cache, new IgniteRunnable() {
+                        @Override public void run() {
+                            cache.invoke(k, new TestEntryProcessor());
+                        }
+                    }, null, null, 1);
+                }
+
+                for (int i = 0; i < 50; i++) {
+                    final int k = key++;
+
+                    checkReadThrough(cache, new IgniteRunnable() {
+                        @Override public void run() {
+                            cache.put(k, k);
+                        }
+                    }, null, null, 0);
+                }
+
+                if (ccfg.getAtomicityMode() == TRANSACTIONAL) {
+                    for (TransactionConcurrency concurrency : TransactionConcurrency.values())
{
+                        for (TransactionIsolation isolation : values()) {
+                            log.info("Test tx [concurrency=" + concurrency + ", isolation="
+ isolation + ']');
+
+                            for (int i = 0; i < 50; i++) {
+                                final int k = key++;
+
+                                checkReadThrough(cache, new IgniteRunnable() {
+                                    @Override public void run() {
+                                        cache.invoke(k, new TestEntryProcessor());
+                                    }
+                                }, concurrency, isolation, 2);
+                            }
+                        }
+                    }
+                }
+            }
+
+            ignite0.cache(ccfg.getName()).removeAll();
+        }
+        finally {
+            ignite0.destroyCache(ccfg.getName());
+        }
+    }
+
+    /**
+     * @param cache Cache.
+     * @param c Cache operation Closure.
+     * @param concurrency Transaction concurrency.
+     * @param isolation Transaction isolation.
+     * @param expLoadCnt Expected number of store 'load' calls.
+     * @throws Exception If failed.
+     */
+    private void checkReadThrough(IgniteCache<Object, Object> cache,
+        IgniteRunnable c,
+        @Nullable TransactionConcurrency concurrency,
+        @Nullable TransactionIsolation isolation,
+        int expLoadCnt) throws Exception {
+        TestStore.loadCnt.set(0);
+
+        Transaction tx = isolation != null ? cache.unwrap(Ignite.class).transactions().txStart(concurrency,
isolation)
+            : null;
+
+        try {
+            c.run();
+
+            if (tx != null)
+                tx.commit();
+        }
+        finally {
+            if (tx != null)
+                tx.close();
+        }
+
+        assertEquals(expLoadCnt, TestStore.loadCnt.get());
+    }
+
+    /**
+     * @param cacheMode Cache mode.
+     * @param atomicityMode Atomicity mode.
+     * @param backups Number of backups.
+     * @return Cache configuration.
+     */
+    @SuppressWarnings("unchecked")
+    protected CacheConfiguration<Object, Object> cacheConfiguration(CacheMode cacheMode,
+        CacheAtomicityMode atomicityMode,
+        int backups) {
+        CacheConfiguration ccfg = new CacheConfiguration();
+
+        ccfg.setReadThrough(true);
+        ccfg.setWriteThrough(true);
+        ccfg.setCacheStoreFactory(new TestStoreFactory());
+        ccfg.setWriteSynchronizationMode(FULL_SYNC);
+        ccfg.setAtomicityMode(atomicityMode);
+        ccfg.setCacheMode(cacheMode);
+        ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
+        ccfg.setAtomicWriteOrderMode(PRIMARY);
+
+        if (cacheMode == PARTITIONED)
+            ccfg.setBackups(backups);
+
+        return ccfg;
+    }
+
+    /**
+     *
+     */
+    public static class TestStoreFactory implements Factory<CacheStore> {
+        /** {@inheritDoc} */
+        @Override public CacheStore create() {
+            return new TestStore();
+        }
+    }
+
+    /**
+     *
+     */
+    public static class TestStore extends CacheStoreAdapter<Object, Object> {
+        /** */
+        static AtomicInteger loadCnt = new AtomicInteger();
+
+        /** {@inheritDoc} */
+        @Override public void loadCache(IgniteBiInClosure<Object, Object> clo, Object...
args) {
+            fail();
+        }
+
+        /** {@inheritDoc} */
+        @Override public Object load(Object key) {
+            loadCnt.incrementAndGet();
+
+            return storeMap.get(key);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void write(Cache.Entry<?, ?> entry) {
+            storeMap.put(entry.getKey(), entry.getValue());
+        }
+
+        /** {@inheritDoc} */
+        @Override public void delete(Object key) {
+            storeMap.remove(key);
+        }
+    }
+
+    /**
+     *
+     */
+    static class TestEntryProcessor implements EntryProcessor<Object, Object, Object>
{
+        /** {@inheritDoc} */
+        @Override public Object process(MutableEntry<Object, Object> entry, Object...
args) {
+            Object val = entry.getValue();
+
+            entry.setValue(entry.getKey());
+
+            return val;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/84a9161e/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
index 9416af3..883f426 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
@@ -68,6 +68,7 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheGetCustomCollectio
 import org.apache.ignite.internal.processors.cache.IgniteCacheInvokeReadThroughSingleNodeTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheInvokeReadThroughTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheLoadRebalanceEvictionSelfTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheReadThroughStoreCallTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheTxCopyOnReadDisabledTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheTxLocalPeekModesTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheTxLocalStoreValueTest;
@@ -206,6 +207,7 @@ public class IgniteCacheTestSuite4 extends TestSuite {
 
         suite.addTestSuite(IgniteCacheInvokeReadThroughSingleNodeTest.class);
         suite.addTestSuite(IgniteCacheInvokeReadThroughTest.class);
+        suite.addTestSuite(IgniteCacheReadThroughStoreCallTest.class);
         suite.addTestSuite(GridCacheVersionMultinodeTest.class);
 
         suite.addTestSuite(IgniteCacheNearReadCommittedTest.class);


Mime
View raw message