ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [2/8] ignite git commit: IGNITE-3699: Fixed ttl calculation for invoke in transaction mode
Date Fri, 09 Dec 2016 09:57:35 GMT
IGNITE-3699: Fixed ttl calculation for invoke in transaction mode


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

Branch: refs/heads/ignite-3699
Commit: ff608f2244cb80d521833d7ecbb5c31c8e81af4b
Parents: 431bdb0
Author: Amir Akhmedov <amir.akhmedov@gmail.com>
Authored: Mon Sep 5 22:30:51 2016 -0400
Committer: Amir Akhmedov <amir.akhmedov@gmail.com>
Committed: Mon Sep 5 22:30:51 2016 -0400

----------------------------------------------------------------------
 .../distributed/dht/GridDhtTxPrepareFuture.java |  4 ++-
 ...eCacheExpiryPolicyWithStoreAbstractTest.java | 33 +++++++++++++++++++-
 2 files changed, 35 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ff608f22/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 3cb0fbc..a6f9033 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
@@ -432,7 +432,9 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
 
                             if (op == NOOP) {
                                 if (expiry != null) {
-                                    long ttl = CU.toTtl(expiry.getExpiryForAccess());
+                                    long ttl = txEntry.previousValue() == null ?
+                                            CU.toTtl(expiry.getExpiryForCreation()) :
+                                            CU.toTtl(expiry.getExpiryForAccess());
 
                                     txEntry.ttl(ttl);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff608f22/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java
index fb0254a..a88443e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java
@@ -25,7 +25,6 @@ import javax.cache.integration.CompletionListenerFuture;
 import javax.cache.processor.EntryProcessor;
 import javax.cache.processor.MutableEntry;
 import org.apache.ignite.IgniteCache;
-import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.cache.store.CacheStore;
 import org.apache.ignite.configuration.CacheConfiguration;
@@ -149,6 +148,38 @@ public abstract class IgniteCacheExpiryPolicyWithStoreAbstractTest extends
Ignit
         storeMap.put(key, 100);
 
         try {
+            Integer res = cache.invoke(key, new EntryProcessor<Integer, Integer, Integer>()
{
+                @Override public Integer process(MutableEntry<Integer, Integer> e,
Object... args) {
+                    return e.getValue();
+                }
+            });
+
+            assertEquals((Integer)100, res);
+
+            checkTtl(key, 500, true);
+
+            assertEquals((Integer)100, cache.localPeek(key, CachePeekMode.ONHEAP));
+
+            U.sleep(600);
+
+            checkExpired(key);
+        }
+        finally {
+            cache.removeAll();
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testGetReadThrough() throws Exception {
+        IgniteCache<Integer, Integer> cache = jcache(0);
+
+        final Integer key = primaryKeys(cache, 1, 100_000).get(0);
+
+        storeMap.put(key, 100);
+
+        try {
             Integer res = cache.get(key);
 
             assertEquals((Integer)100, res);


Mime
View raw message