ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovi...@apache.org
Subject [36/50] [abbrv] incubator-ignite git commit: # Refactoring: introduced common method to calculate TTL for store load operation.
Date Fri, 20 Feb 2015 02:50:34 GMT
# Refactoring: introduced common method to calculate TTL for store load operation.


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

Branch: refs/heads/ignite-281
Commit: 7cb404d9c93da702478ce676c09b41f287af5baf
Parents: bc6553b
Author: vozerov <vozerov@gridgain.com>
Authored: Thu Feb 19 15:12:55 2015 +0300
Committer: vozerov <vozerov@gridgain.com>
Committed: Thu Feb 19 15:12:55 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheAdapter.java      | 24 +++++---------------
 .../processors/cache/GridCacheUtils.java        | 19 ++++++++++++++++
 .../distributed/dht/GridDhtCacheAdapter.java    | 12 +++-------
 3 files changed, 28 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7cb404d9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 808c62f..1ec8685 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -3901,16 +3901,10 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K,
V>,
                     throws IgniteException {
                     assert ver == null;
 
-                    long ttl = 0;
+                    long ttl = CU.ttlForLoad(plc);
 
-                    if (plc != null) {
-                        ttl = CU.toTtl(plc.getExpiryForCreation());
-
-                        if (ttl == CU.TTL_ZERO)
-                            return;
-                        else if (ttl == CU.TTL_NOT_CHANGED)
-                            ttl = 0;
-                    }
+                    if (ttl == CU.TTL_ZERO)
+                        return;
 
                     loadEntry(key, val, ver0, p, topVer, replicate, ttl);
                 }
@@ -4114,16 +4108,10 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K,
V>,
 
             ctx.store().loadAllFromStore(null, keys, new CI2<K, V>() {
                 @Override public void apply(K key, V val) {
-                    long ttl = 0;
+                    long ttl = CU.ttlForLoad(plc0);
 
-                    if (plc0 != null) {
-                        ttl = CU.toTtl(plc0.getExpiryForCreation());
-
-                        if (ttl == CU.TTL_ZERO)
-                            return;
-                        else if (ttl == CU.TTL_NOT_CHANGED)
-                            ttl = 0;
-                    }
+                    if (ttl == CU.TTL_ZERO)
+                        return;
 
                     loadEntry(key, val, ver0, null, topVer, replicate, ttl);
                 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7cb404d9/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 7f8b278..bc0a5cd 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
@@ -1712,6 +1712,25 @@ public class GridCacheUtils {
     }
 
     /**
+     * Get TTL for load operation.
+     *
+     * @param plc Expiry policy.
+     * @return TTL for load operation or {@link #TTL_ZERO} in case of immediate expiration.
+     */
+    public static Long ttlForLoad(ExpiryPolicy plc) {
+        if (plc != null) {
+            long ttl = toTtl(plc.getExpiryForCreation());
+
+            if (ttl == TTL_NOT_CHANGED)
+                ttl = TTL_ETERNAL;
+
+            return ttl;
+        }
+        else
+            return TTL_ETERNAL;
+    }
+
+    /**
      * @return Expire time denoting a point in the past.
      */
     public static long expireTimeInPast() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7cb404d9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
index 50c7910..0527ab1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
@@ -440,16 +440,10 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
                 GridCacheEntryEx<K, V> entry = null;
 
                 try {
-                    long ttl = 0;
+                    long ttl = CU.ttlForLoad(plc);
 
-                    if (plc != null) {
-                        ttl = CU.toTtl(plc.getExpiryForCreation());
-
-                        if (ttl == CU.TTL_ZERO)
-                            return;
-                        else if (ttl == CU.TTL_NOT_CHANGED)
-                            ttl = 0;
-                    }
+                    if (ttl == CU.TTL_ZERO)
+                        return;
 
                     if (ctx.portableEnabled()) {
                         key = (K)ctx.marshalToPortable(key);


Mime
View raw message