You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by pt...@apache.org on 2015/06/03 05:42:57 UTC

[4/9] storm git commit: Added expireIntervalSec to RedisClusterMapState.Options

Added expireIntervalSec to RedisClusterMapState.Options

Just as I added this to RedisMapState.Options to match the setting
available in the Redis[Cluster]StateUpdater classes.


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

Branch: refs/heads/master
Commit: 306c535fb3e7fb5522e9cd2e0f41ba4c9fa8f9ca
Parents: 2059f23
Author: eric-mulvaney <er...@kontagent.com>
Authored: Wed Apr 8 14:37:06 2015 -0400
Committer: eric-mulvaney <er...@kontagent.com>
Committed: Wed Apr 8 14:37:06 2015 -0400

----------------------------------------------------------------------
 .../storm/redis/trident/state/RedisClusterMapState.java  | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/306c535f/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterMapState.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterMapState.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterMapState.java
index e47330b..7bcbb6c 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterMapState.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterMapState.java
@@ -75,6 +75,7 @@ public class RedisClusterMapState<T> implements IBackingMap<T> {
         public KeyFactory keyFactory = null;
         public Serializer<T> serializer = null;
         public String hkey = null;
+        public int expireIntervalSec = 0;
     }
 
     public static interface KeyFactory extends Serializable {
@@ -276,11 +277,16 @@ public class RedisClusterMapState<T> implements IBackingMap<T> {
             return;
         }
 
+        final int expireIntervalSec = this.options.expireIntervalSec;
         if (Strings.isNullOrEmpty(this.options.hkey)) {
             for (int i = 0; i < keys.size(); i++) {
                 String val = new String(serializer.serialize(vals.get(i)));
                 String redisKey = keyFactory.build(keys.get(i));
-                jedisCluster.set(redisKey, val);
+                if (expireIntervalSec > 0) {
+                    jedisCluster.setex(redisKey, expireIntervalSec, val);
+                } else {
+                    jedisCluster.set(redisKey, val);
+                }
             }
         } else {
             Map<String, String> keyValues = new HashMap<String, String>();
@@ -289,6 +295,9 @@ public class RedisClusterMapState<T> implements IBackingMap<T> {
                 keyValues.put(keyFactory.build(keys.get(i)), val);
             }
             jedisCluster.hmset(this.options.hkey, keyValues);
+            if (expireIntervalSec > 0) {
+                jedisCluster.expire(this.options.hkey, expireIntervalSec);
+            }
         }
     }
 }