storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kabh...@apache.org
Subject [1/3] storm git commit: [STORM-2553] Add support for password in JedisCluster
Date Thu, 22 Jun 2017 03:36:54 GMT
Repository: storm
Updated Branches:
  refs/heads/1.x-branch b0349448f -> 9588af4c8


[STORM-2553] Add support for password in JedisCluster


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

Branch: refs/heads/1.x-branch
Commit: 244e5c433e1c2e6ea9d161b8b5619884d5057ad0
Parents: b034944
Author: yan guotao <yan_guotao@126.com>
Authored: Fri Jun 16 18:20:02 2017 +0800
Committer: Jungtaek Lim <kabhwan@gmail.com>
Committed: Thu Jun 22 12:31:08 2017 +0900

----------------------------------------------------------------------
 external/storm-redis/pom.xml                    |  2 +-
 .../redis/common/config/JedisClusterConfig.java | 40 +++++++++++++++++++-
 .../JedisCommandsContainerBuilder.java          |  2 +-
 .../trident/state/RedisClusterMapState.java     |  2 +
 .../redis/trident/state/RedisClusterState.java  |  2 +
 5 files changed, 45 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/244e5c43/external/storm-redis/pom.xml
----------------------------------------------------------------------
diff --git a/external/storm-redis/pom.xml b/external/storm-redis/pom.xml
index fff5d88..73dd324 100644
--- a/external/storm-redis/pom.xml
+++ b/external/storm-redis/pom.xml
@@ -41,7 +41,7 @@
     </developers>
 
     <properties>
-        <jedis.version>2.8.1</jedis.version>
+        <jedis.version>2.9.0</jedis.version>
     </properties>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/storm/blob/244e5c43/external/storm-redis/src/main/java/org/apache/storm/redis/common/config/JedisClusterConfig.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/common/config/JedisClusterConfig.java
b/external/storm-redis/src/main/java/org/apache/storm/redis/common/config/JedisClusterConfig.java
index d8696aa..882fc01 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/common/config/JedisClusterConfig.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/common/config/JedisClusterConfig.java
@@ -33,6 +33,7 @@ public class JedisClusterConfig implements Serializable {
     private Set<InetSocketAddress> nodes;
     private int timeout;
     private int maxRedirections;
+    private String password;
 
     /**
      * Constructor
@@ -47,11 +48,29 @@ public class JedisClusterConfig implements Serializable {
      * @throws NullPointerException when you didn't set nodes
      */
     public JedisClusterConfig(Set<InetSocketAddress> nodes, int timeout, int maxRedirections)
{
+        this(nodes, timeout, maxRedirections, null);
+    }
+
+    /**
+     * Constructor
+     * <p/>
+     * You can use JedisClusterConfig.Builder() for leaving some fields to apply default
value.
+     * <p/>
+     * Note that list of node is mandatory, and when you didn't set nodes, it throws NullPointerException.
+     *
+     * @param nodes list of node information for JedisCluster
+     * @param timeout socket / connection timeout
+     * @param maxRedirections limit of redirections - how much we'll follow MOVED or ASK
+     * @param password password, if any
+     * @throws NullPointerException when you didn't set nodes
+     */
+    public JedisClusterConfig(Set<InetSocketAddress> nodes, int timeout, int maxRedirections,
String password) {
         Preconditions.checkNotNull(nodes, "Node information should be presented");
 
         this.nodes = nodes;
         this.timeout = timeout;
         this.maxRedirections = maxRedirections;
+        this.password = password;
     }
 
     /**
@@ -83,12 +102,21 @@ public class JedisClusterConfig implements Serializable {
     }
 
     /**
+     * Returns password.
+     * @return password
+     */
+    public String getPassword() {
+        return password;
+    }
+
+    /**
      * Builder for initializing JedisClusterConfig.
      */
     public static class Builder {
         private Set<InetSocketAddress> nodes;
         private int timeout = Protocol.DEFAULT_TIMEOUT;
         private int maxRedirections = 5;
+        private String password;
 
         /**
          * Sets list of node.
@@ -121,11 +149,21 @@ public class JedisClusterConfig implements Serializable {
         }
 
         /**
+         * Sets password.
+         * @param password password, if any
+         * @return Builder itself
+         */
+        public Builder setPassword(String password) {
+            this.password = password;
+            return this;
+        }
+
+        /**
          * Builds JedisClusterConfig.
          * @return JedisClusterConfig
          */
         public JedisClusterConfig build() {
-            return new JedisClusterConfig(nodes, timeout, maxRedirections);
+            return new JedisClusterConfig(nodes, timeout, maxRedirections, password);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/storm/blob/244e5c43/external/storm-redis/src/main/java/org/apache/storm/redis/common/container/JedisCommandsContainerBuilder.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/common/container/JedisCommandsContainerBuilder.java
b/external/storm-redis/src/main/java/org/apache/storm/redis/common/container/JedisCommandsContainerBuilder.java
index 36a74d6..dc24396 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/common/container/JedisCommandsContainerBuilder.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/common/container/JedisCommandsContainerBuilder.java
@@ -47,7 +47,7 @@ public class JedisCommandsContainerBuilder {
      * @return container for Redis Cluster environment
      */
     public static JedisCommandsInstanceContainer build(JedisClusterConfig config) {
-        JedisCluster jedisCluster = new JedisCluster(config.getNodes(), config.getTimeout(),
config.getMaxRedirections(), DEFAULT_POOL_CONFIG);
+        JedisCluster jedisCluster = new JedisCluster(config.getNodes(), config.getTimeout(),
config.getTimeout(), config.getMaxRedirections(), config.getPassword(), DEFAULT_POOL_CONFIG);
         return new JedisClusterContainer(jedisCluster);
     }
 }

http://git-wip-us.apache.org/repos/asf/storm/blob/244e5c43/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 54e9aea..6ba0515 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
@@ -232,7 +232,9 @@ public class RedisClusterMapState<T> extends AbstractRedisMapState<T>
{
         public State makeState(@SuppressWarnings("rawtypes") Map conf, IMetricsContext metrics,
int partitionIndex, int numPartitions) {
             JedisCluster jedisCluster = new JedisCluster(jedisClusterConfig.getNodes(),
                                                             jedisClusterConfig.getTimeout(),
+                                                            jedisClusterConfig.getTimeout(),
                                                             jedisClusterConfig.getMaxRedirections(),
+                                                            jedisClusterConfig.getPassword(),
                                                             DEFAULT_POOL_CONFIG);
 
             RedisClusterMapState state = new RedisClusterMapState(jedisCluster, options,
serializer, keyFactory);

http://git-wip-us.apache.org/repos/asf/storm/blob/244e5c43/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterState.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterState.java
b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterState.java
index c773c1a..ead27e0 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterState.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterState.java
@@ -71,7 +71,9 @@ public class RedisClusterState implements State {
         public State makeState(@SuppressWarnings("rawtypes") Map conf, IMetricsContext metrics,
int partitionIndex, int numPartitions) {
             JedisCluster jedisCluster = new JedisCluster(jedisClusterConfig.getNodes(),
                                                     jedisClusterConfig.getTimeout(),
+                                                    jedisClusterConfig.getTimeout(),
                                                     jedisClusterConfig.getMaxRedirections(),
+                                                    jedisClusterConfig.getPassword(),
                                                     DEFAULT_POOL_CONFIG);
 
             return new RedisClusterState(jedisCluster);


Mime
View raw message