ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [3/5] incubator-ignite git commit: # IGNITE-283: Fixed assertion.
Date Fri, 20 Feb 2015 07:04:45 GMT
# IGNITE-283: Fixed assertion.


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

Branch: refs/heads/ignite-283-tx
Commit: 43128cb03be84a248120b0a91211af7e3fb0b476
Parents: 404a695
Author: vozerov <vozerov@gridgain.com>
Authored: Thu Feb 19 17:28:59 2015 +0300
Committer: vozerov <vozerov@gridgain.com>
Committed: Thu Feb 19 17:28:59 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheMapEntry.java     | 54 +++++++++++---------
 .../dht/atomic/GridDhtAtomicCache.java          |  2 +-
 2 files changed, 32 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/43128cb0/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 c9b9a36..00b69ca 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
@@ -1576,6 +1576,11 @@ public abstract class GridCacheMapEntry<K, V> implements GridCacheEntryEx<K,
V>
 
         EntryProcessorResult<?> invokeRes = null;
 
+        // System TTL/ET which may have special values.
+        long newSysTtl;
+        long newSysExpireTime;
+
+        // TTL/ET which will be passed to entry on update.
         long newTtl;
         long newExpireTime;
 
@@ -1856,41 +1861,50 @@ public abstract class GridCacheMapEntry<K, V> implements GridCacheEntryEx<K,
V>
                     // Calculate TTL and expire time for local update.
                     if (explicitTtl != CU.TTL_NOT_CHANGED) {
                         // TTL/expireTime was sent to us from node where conflict had been
resolved.
-                        newTtl = explicitTtl;
-                        newExpireTime = explicitExpireTime;
+                        assert explicitExpireTime != CU.EXPIRE_TIME_CALCULATE;
+
+                        newSysTtl = newTtl = explicitTtl;
+                        newSysExpireTime = newExpireTime = explicitExpireTime;
                     }
                     else {
-                        if (expiryPlc != null)
-                            newTtl = hadVal ? expiryPlc.forUpdate() : expiryPlc.forCreate();
-                        else
-                            newTtl = CU.TTL_NOT_CHANGED;
+                        newSysTtl = expiryPlc == null ? CU.TTL_NOT_CHANGED :
+                            hadVal ? expiryPlc.forUpdate() : expiryPlc.forCreate();
 
-                        if (newTtl == CU.TTL_NOT_CHANGED) {
+                        if (newSysTtl == CU.TTL_NOT_CHANGED) {
+                            newSysExpireTime = CU.EXPIRE_TIME_CALCULATE;
                             newTtl = ttlExtras();
                             newExpireTime = expireTimeExtras();
                         }
-                        else if (newTtl == CU.TTL_ZERO) {
+                        else if (newSysTtl == CU.TTL_ZERO) {
                             op = GridCacheOperation.DELETE;
 
-                            // This is delete, so make TTL and expire time eternal.
+                            newSysTtl = CU.TTL_NOT_CHANGED;
+                            newSysExpireTime = CU.EXPIRE_TIME_CALCULATE;
+
                             newTtl = CU.TTL_ETERNAL;
                             newExpireTime = CU.EXPIRE_TIME_ETERNAL;
 
                             updated = null;
                             valBytes = null;
                         }
-                        else
+                        else {
+                            newSysExpireTime = CU.EXPIRE_TIME_CALCULATE;
+                            newTtl = newSysTtl;
                             newExpireTime = CU.toExpireTime(newTtl);
+                        }
                     }
                 }
                 else {
-                    newTtl = conflictCtx.ttl();
-                    newExpireTime = conflictCtx.expireTime();
+                    newSysTtl = newTtl = conflictCtx.ttl();
+                    newSysExpireTime = newExpireTime = conflictCtx.expireTime();
                 }
             }
             else {
                 assert op == GridCacheOperation.DELETE;
 
+                newSysTtl = CU.TTL_NOT_CHANGED;
+                newSysExpireTime = CU.EXPIRE_TIME_CALCULATE;
+
                 newTtl = CU.TTL_ETERNAL;
                 newExpireTime = CU.EXPIRE_TIME_ETERNAL;
             }
@@ -2024,10 +2038,10 @@ public abstract class GridCacheMapEntry<K, V> implements GridCacheEntryEx<K,
V>
                 boolean hasValPtr = valPtr != 0;
 
                 // Clear value on backup. Entry will be removed from cache when it got evicted
from queue.
-                assert newTtl == CU.TTL_ETERNAL;
-                assert newExpireTime == CU.EXPIRE_TIME_ETERNAL;
+                update(null, null, CU.TTL_ETERNAL, CU.EXPIRE_TIME_ETERNAL, newVer);
 
-                update(null, null, newTtl, newExpireTime, newVer);
+                assert newSysTtl == CU.TTL_NOT_CHANGED;
+                assert newSysExpireTime == CU.EXPIRE_TIME_CALCULATE;
 
                 if (cctx.offheapTiered() && hasValPtr) {
                     boolean rmv = cctx.swap().removeOffheap(key, getOrMarshalKeyBytes());
@@ -2088,18 +2102,12 @@ public abstract class GridCacheMapEntry<K, V> implements GridCacheEntryEx<K,
V>
         if (log.isDebugEnabled())
             log.debug("Updated cache entry [val=" + val + ", old=" + oldVal + ", entry="
+ this + ']');
 
-        // Ensure that TTL / expire stuff is not sent over wire when not needed.
-        if (!res || op == GridCacheOperation.DELETE) {
-            newTtl = CU.TTL_NOT_CHANGED;
-            newExpireTime = CU.EXPIRE_TIME_CALCULATE;
-        }
-
         return new GridCacheUpdateAtomicResult<>(res,
             oldVal,
             updated,
             invokeRes,
-            newTtl,
-            newExpireTime,
+            newSysTtl,
+            newSysExpireTime,
             enqueueVer,
             conflictCtx,
             true);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/43128cb0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index fe037e5..218cd33 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -1985,7 +1985,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K,
V> {
                         req.subjectId(),
                         taskName);
 
-                    //assert updRes.newTtl() == CU.TTL_NOT_CHANGED || expiry != null;
+                    assert updRes.newTtl() == CU.TTL_NOT_CHANGED || expiry != null;
 
                     if (intercept) {
                         if (op == UPDATE)


Mime
View raw message