You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by bo...@apache.org on 2015/02/23 17:26:14 UTC

[01/23] storm git commit: add storm-redis to storm

Repository: storm
Updated Branches:
  refs/heads/master 9d0df23b5 -> 4b6e43b81


add storm-redis to storm


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

Branch: refs/heads/master
Commit: 741a14c78d64daa4bca4c2119dda8eae589ccd48
Parents: 66be747
Author: dashengju <da...@qq.com>
Authored: Fri Dec 26 13:51:42 2014 +0800
Committer: dashengju <da...@qq.com>
Committed: Fri Dec 26 13:51:42 2014 +0800

----------------------------------------------------------------------
 external/storm-redis/LICENSE                    | 202 ++++++++++++
 external/storm-redis/README.md                  |  59 ++++
 external/storm-redis/pom.xml                    |  65 ++++
 .../trident/mapper/TridentTupleMapper.java      |  27 ++
 .../trident/state/RedisClusterMapState.java     | 237 ++++++++++++++
 .../redis/trident/state/RedisClusterState.java  | 190 +++++++++++
 .../state/RedisClusterStateSetCountQuerier.java |  66 ++++
 .../state/RedisClusterStateSetUpdater.java      |  72 +++++
 .../redis/trident/state/RedisMapState.java      | 314 +++++++++++++++++++
 .../trident/state/RedisMapStateExample.java     | 101 ++++++
 pom.xml                                         |   1 +
 11 files changed, 1334 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/741a14c7/external/storm-redis/LICENSE
----------------------------------------------------------------------
diff --git a/external/storm-redis/LICENSE b/external/storm-redis/LICENSE
new file mode 100644
index 0000000..e06d208
--- /dev/null
+++ b/external/storm-redis/LICENSE
@@ -0,0 +1,202 @@
+Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "{}"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright {yyyy} {name of copyright owner}
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+

http://git-wip-us.apache.org/repos/asf/storm/blob/741a14c7/external/storm-redis/README.md
----------------------------------------------------------------------
diff --git a/external/storm-redis/README.md b/external/storm-redis/README.md
new file mode 100644
index 0000000..3f5fa55
--- /dev/null
+++ b/external/storm-redis/README.md
@@ -0,0 +1,59 @@
+#Storm Redis
+
+Storm/Trident integration for [Redis](http://redis.io/)
+
+## Usage
+
+### How do I use it?
+
+You can download the latest build at:
+    http://github.com/dashengju/storm-redis/releases
+
+Or use it as a maven dependency:
+
+```xml
+<repositories>
+    <repository>
+        <id>storm-redis</id>
+        <url>https://raw.github.com/dashengju/storm-redis/mvn-repo/</url>
+        <snapshots>
+            <enabled>true</enabled>
+            <updatePolicy>always</updatePolicy>
+        </snapshots>
+    </repository>
+</repositories>
+```
+
+```xml
+<dependency>
+    <groupId>org.apache.storm</groupId>
+    <artifactId>storm-redis</artifactId>
+    <version>1.0.1</version>
+    <type>jar</type>
+    <scope>compile</scope>
+</dependency>
+```
+
+## License
+
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+
+## Committer Sponsors
+
+ * DashengJu ([dashengju@gmail.com](mailto:dashengju@gmail.com))
+ 

http://git-wip-us.apache.org/repos/asf/storm/blob/741a14c7/external/storm-redis/pom.xml
----------------------------------------------------------------------
diff --git a/external/storm-redis/pom.xml b/external/storm-redis/pom.xml
new file mode 100644
index 0000000..1f23e90
--- /dev/null
+++ b/external/storm-redis/pom.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <artifactId>storm</artifactId>
+        <groupId>org.apache.storm</groupId>
+        <version>0.10.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>storm-redis</artifactId>
+
+    <developers>
+        <developer>
+            <id>dashengju</id>
+            <name>Dasheng Ju</name>
+            <email>dashengju@gmail.com</email>
+        </developer>
+    </developers>
+
+    <properties>
+        <jedis.version>2.6.1</jedis.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.storm</groupId>
+            <artifactId>storm-core</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>redis.clients</groupId>
+            <artifactId>jedis</artifactId>
+            <version>${jedis.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.zookeeper</groupId>
+                    <artifactId>zookeeper</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/storm/blob/741a14c7/external/storm-redis/src/main/java/org/apache/storm/redis/trident/mapper/TridentTupleMapper.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/mapper/TridentTupleMapper.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/mapper/TridentTupleMapper.java
new file mode 100644
index 0000000..4c10143
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/mapper/TridentTupleMapper.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident.mapper;
+
+import storm.trident.tuple.TridentTuple;
+
+import java.io.Serializable;
+
+public interface TridentTupleMapper extends Serializable {
+    public String getKeyFromTridentTuple(TridentTuple tuple);
+    public String getValueFromTridentTuple(TridentTuple tuple);
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/741a14c7/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
new file mode 100644
index 0000000..b062a53
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterMapState.java
@@ -0,0 +1,237 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident.state;
+
+import backtype.storm.task.IMetricsContext;
+import backtype.storm.tuple.Values;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+import redis.clients.jedis.Protocol;
+import storm.trident.state.JSONNonTransactionalSerializer;
+import storm.trident.state.JSONOpaqueSerializer;
+import storm.trident.state.JSONTransactionalSerializer;
+import storm.trident.state.OpaqueValue;
+import storm.trident.state.Serializer;
+import storm.trident.state.State;
+import storm.trident.state.StateFactory;
+import storm.trident.state.StateType;
+import storm.trident.state.TransactionalValue;
+import storm.trident.state.map.CachedMap;
+import storm.trident.state.map.IBackingMap;
+import storm.trident.state.map.MapState;
+import storm.trident.state.map.NonTransactionalMap;
+import storm.trident.state.map.OpaqueMap;
+import storm.trident.state.map.SnapshottableMap;
+import storm.trident.state.map.TransactionalMap;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RedisClusterMapState<T> implements IBackingMap<T> {
+    private static final Logger logger = LoggerFactory.getLogger(RedisClusterMapState.class);
+
+    private static final EnumMap<StateType, Serializer> DEFAULT_SERIALIZERS = Maps.newEnumMap(ImmutableMap.of(
+            StateType.NON_TRANSACTIONAL, new JSONNonTransactionalSerializer(),
+            StateType.TRANSACTIONAL, new JSONTransactionalSerializer(),
+            StateType.OPAQUE, new JSONOpaqueSerializer()
+    ));
+
+    public static class DefaultKeyFactory implements KeyFactory {
+        public String build(List<Object> key) {
+            if (key.size() != 1)
+                throw new RuntimeException("Default KeyFactory does not support compound keys");
+            return (String) key.get(0);
+        }
+    };
+
+    public static class Options<T> implements Serializable {
+        public int localCacheSize = 1000;
+        public String globalKey = "$REDIS-MAP-STATE-GLOBAL";
+        public Serializer<T> serializer = null;
+        public KeyFactory keyFactory = null;
+        public int connectionTimeout = Protocol.DEFAULT_TIMEOUT;
+        public int maxRedirections = 10;
+        public String password = null;
+        public int database = Protocol.DEFAULT_DATABASE;
+    }
+
+    public static interface KeyFactory extends Serializable {
+        String build(List<Object> key);
+    }
+
+    public static StateFactory opaque(Set<HostAndPort> clusterNodes) {
+        return opaque(clusterNodes, new Options());
+    }
+
+    public static StateFactory opaque(Set<HostAndPort> clusterNodes, Options<OpaqueValue> opts) {
+        return opaque(clusterNodes, opts, new DefaultKeyFactory());
+    }
+
+    public static StateFactory opaque(Set<HostAndPort> clusterNodes, Options<OpaqueValue> opts, KeyFactory factory) {
+        return new Factory(clusterNodes, StateType.OPAQUE, opts, factory);
+    }
+
+    public static StateFactory transactional(Set<HostAndPort> clusterNodes) {
+        return transactional(clusterNodes, new Options());
+    }
+
+    public static StateFactory transactional(Set<HostAndPort> clusterNodes, Options<TransactionalValue> opts) {
+        return transactional(clusterNodes, opts, new DefaultKeyFactory());
+    }
+
+    public static StateFactory transactional(Set<HostAndPort> clusterNodes, Options<TransactionalValue> opts, KeyFactory factory) {
+        return new Factory(clusterNodes, StateType.TRANSACTIONAL, opts, factory);
+    }
+
+    public static StateFactory nonTransactional(Set<HostAndPort> clusterNodes) {
+        return nonTransactional(clusterNodes, new Options());
+    }
+
+    public static StateFactory nonTransactional(Set<HostAndPort> clusterNodes, Options<Object> opts) {
+        return nonTransactional(clusterNodes, opts, new DefaultKeyFactory());
+    }
+
+    public static StateFactory nonTransactional(Set<HostAndPort> clusterNodes, Options<Object> opts, KeyFactory factory) {
+        return new Factory(clusterNodes, StateType.NON_TRANSACTIONAL, opts, factory);
+    }
+
+    protected static class Factory implements StateFactory {
+        StateType type;
+        Set<HostAndPort> clusterNodes;
+        Serializer serializer;
+        KeyFactory factory;
+        Options options;
+
+        public Factory(Set<HostAndPort> clusterNodes, StateType type, Options options, KeyFactory factory) {
+            this.type = type;
+            this.clusterNodes = clusterNodes;
+            this.options = options;
+            this.factory = factory;
+
+            if (options.serializer == null) {
+                serializer = DEFAULT_SERIALIZERS.get(type);
+                if (serializer == null) {
+                    throw new RuntimeException("Couldn't find serializer for state type: " + type);
+                }
+            } else {
+                this.serializer = options.serializer;
+            }
+        }
+
+        public State makeState(@SuppressWarnings("rawtypes") Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
+            JedisCluster jc = new JedisCluster(clusterNodes, options.connectionTimeout, options.maxRedirections);
+            RedisClusterMapState state = new RedisClusterMapState(jc, options, serializer, factory);
+            CachedMap c = new CachedMap(state, options.localCacheSize);
+
+            MapState ms;
+            if (type == StateType.NON_TRANSACTIONAL) {
+                ms = NonTransactionalMap.build(c);
+
+            } else if (type == StateType.OPAQUE) {
+                ms = OpaqueMap.build(c);
+
+            } else if (type == StateType.TRANSACTIONAL) {
+                ms = TransactionalMap.build(c);
+
+            } else {
+                throw new RuntimeException("Unknown state type: " + type);
+            }
+
+            return new SnapshottableMap(ms, new Values(options.globalKey));
+        }
+    }
+
+    private final JedisCluster jedisCluster;
+    private Options options;
+    private Serializer serializer;
+    private KeyFactory keyFactory;
+
+    public RedisClusterMapState(JedisCluster jedisCluster, Options options, Serializer<T> serializer, KeyFactory keyFactory) {
+        this.jedisCluster = jedisCluster;
+        this.options = options;
+        this.serializer = serializer;
+        this.keyFactory = keyFactory;
+    }
+
+    public List<T> multiGet(List<List<Object>> keys) {
+        if (keys.size() == 0) {
+            return Collections.emptyList();
+        }
+
+        String[] stringKeys = buildKeys(keys);
+        List<String> values = mget(stringKeys);
+        return deserializeValues(keys, values);
+    }
+
+    private List<T> deserializeValues(List<List<Object>> keys, List<String> values) {
+        List<T> result = new ArrayList<T>(keys.size());
+        for (String value : values) {
+            if (value != null) {
+                result.add((T) serializer.deserialize(value.getBytes()));
+            } else {
+                result.add(null);
+            }
+        }
+        return result;
+    }
+
+    private String[] buildKeys(List<List<Object>> keys) {
+        String[] stringKeys = new String[keys.size()];
+        int index = 0;
+        for (List<Object> key : keys)
+            stringKeys[index++] = keyFactory.build(key);
+        return stringKeys;
+    }
+
+    private List<String> mget(String... keys) {
+        List<String> rets = new ArrayList<String>();
+        for (String key : keys) {
+            rets.add(jedisCluster.get(key));
+        }
+        return rets;
+    }
+
+    public void multiPut(List<List<Object>> keys, List<T> vals) {
+        if (keys.size() == 0) {
+            return;
+        }
+        if (keys.size() != vals.size()) {
+            logger.error("multiPut keys.size[" + keys.size() + "] not equal to vals.size[" + vals.size() + "]");
+            return;
+        }
+
+        /**
+         * Todo: because JedisCluster now not support mset, we use for,set to implement multiPut
+         * */
+        for (int i = 0; i < keys.size(); i++) {
+            String redisKey = keyFactory.build(keys.get(i));
+            String val = new String(serializer.serialize(vals.get(i)));
+            jedisCluster.set(redisKey, val);
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/741a14c7/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
new file mode 100644
index 0000000..9ebc87d
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterState.java
@@ -0,0 +1,190 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident.state;
+
+import backtype.storm.task.IMetricsContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+import redis.clients.jedis.Protocol;
+import storm.trident.state.State;
+import storm.trident.state.StateFactory;
+
+import java.io.Serializable;
+import java.net.InetSocketAddress;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RedisClusterState implements State {
+    private static final Logger logger = LoggerFactory.getLogger(RedisClusterState.class);
+
+    @Override
+    public void beginCommit(Long aLong) {
+    }
+
+    @Override
+    public void commit(Long aLong) {
+    }
+
+    public static class Options implements Serializable {
+        public int connectionTimeout = Protocol.DEFAULT_TIMEOUT;
+        public int maxRedirections = 10;
+    }
+
+    public static class Factory implements StateFactory {
+        Set<InetSocketAddress> clusterNodes;
+        Options options;
+
+        public Factory(Set<InetSocketAddress> clusterNodes, Options options) {
+            this.clusterNodes = clusterNodes;
+            this.options = options;
+        }
+
+        public State makeState(@SuppressWarnings("rawtypes") Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
+            Set<HostAndPort> nodes = new HashSet<HostAndPort>();
+            for (InetSocketAddress addr : clusterNodes) {
+                nodes.add(new HostAndPort(addr.getHostName(), addr.getPort()));
+            }
+            JedisCluster jc = new JedisCluster(nodes, options.connectionTimeout, options.maxRedirections);
+            return new RedisClusterState(jc, options);
+        }
+    }
+
+    private final JedisCluster jedisCluster;
+    private Options options;
+
+    public RedisClusterState(JedisCluster jedisCluster, Options options) {
+        this.jedisCluster = jedisCluster;
+        this.options = options;
+    }
+
+    /**
+     * Set a timeout on the specified key. After the timeout the key will be
+     * automatically deleted by the server. A key with an associated timeout is
+     * said to be volatile in Redis terminology.
+     * <p>
+     * Voltile keys are stored on disk like the other keys, the timeout is
+     * persistent too like all the other aspects of the dataset. Saving a
+     * dataset containing expires and stopping the server does not stop the flow
+     * of time as Redis stores on disk the time when the key will no longer be
+     * available as Unix time, and not the remaining seconds.
+     * <p>
+     * Since Redis 2.1.3 you can update the value of the timeout of a key
+     * already having an expire set. It is also possible to undo the expire at
+     * all turning the key into a normal key using the {@link #persist(String)
+     * PERSIST} command.
+     * <p>
+     * Time complexity: O(1)
+     *
+     * @see <ahref="http://code.google.com/p/redis/wiki/ExpireCommand">ExpireCommand</a>
+     *
+     * @param key
+     * @param seconds
+     * @return Integer reply, specifically: 1: the timeout was set. 0: the
+     *         timeout was not set since the key already has an associated
+     *         timeout (this may happen only in Redis versions < 2.1.3, Redis >=
+     *         2.1.3 will happily update the timeout), or the key does not
+     *         exist.
+     */
+    public Long expire(final String key, final int seconds) {
+        return jedisCluster.expire(key, seconds);
+    }
+
+    /**
+     * EXPIREAT works exctly like {@link #expire(String, int) EXPIRE} but
+     * instead to get the number of seconds representing the Time To Live of the
+     * key as a second argument (that is a relative way of specifing the TTL),
+     * it takes an absolute one in the form of a UNIX timestamp (Number of
+     * seconds elapsed since 1 Gen 1970).
+     * <p>
+     * EXPIREAT was introduced in order to implement the Append Only File
+     * persistence mode so that EXPIRE commands are automatically translated
+     * into EXPIREAT commands for the append only file. Of course EXPIREAT can
+     * also used by programmers that need a way to simply specify that a given
+     * key should expire at a given time in the future.
+     * <p>
+     * Since Redis 2.1.3 you can update the value of the timeout of a key
+     * already having an expire set. It is also possible to undo the expire at
+     * all turning the key into a normal key using the {@link #persist(String)
+     * PERSIST} command.
+     * <p>
+     * Time complexity: O(1)
+     *
+     * @see <ahref="http://code.google.com/p/redis/wiki/ExpireCommand">ExpireCommand</a>
+     *
+     * @param key
+     * @param unixTime
+     * @return Integer reply, specifically: 1: the timeout was set. 0: the
+     *         timeout was not set since the key already has an associated
+     *         timeout (this may happen only in Redis versions < 2.1.3, Redis >=
+     *         2.1.3 will happily update the timeout), or the key does not
+     *         exist.
+     */
+    public Long expireAt(final String key, final long unixTime) {
+        return jedisCluster.expireAt(key, unixTime);
+    }
+
+    /**
+     * Undo a {@link #expire(String, int) expire} at turning the expire key into
+     * a normal key.
+     * <p>
+     * Time complexity: O(1)
+     *
+     * @param key
+     * @return Integer reply, specifically: 1: the key is now persist. 0: the
+     *         key is not persist (only happens when key not set).
+     */
+    public Long persist(final String key) {
+        return jedisCluster.persist(key);
+    }
+
+    public Long sadd(final String key, final String... member) {
+        return jedisCluster.sadd(key, member);
+    }
+
+    public Set<String> smembers(final String key) {
+        return jedisCluster.smembers(key);
+    }
+
+    public Long srem(final String key, final String... member) {
+        return jedisCluster.srem(key, member);
+    }
+
+    public String spop(final String key) {
+        return jedisCluster.spop(key);
+    }
+
+    public Long scard(final String key) {
+        return jedisCluster.scard(key);
+    }
+
+    public Boolean sismember(final String key, final String member) {
+        return jedisCluster.sismember(key, member);
+    }
+
+    public String srandmember(final String key) {
+        return jedisCluster.srandmember(key);
+    }
+
+    public List<String> srandmember(final String key, final int count) {
+        return jedisCluster.srandmember(key, count);
+    }
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/741a14c7/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateSetCountQuerier.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateSetCountQuerier.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateSetCountQuerier.java
new file mode 100644
index 0000000..03a9375
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateSetCountQuerier.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident.state;
+
+import backtype.storm.tuple.Values;
+import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import storm.trident.operation.TridentCollector;
+import storm.trident.state.BaseQueryFunction;
+import storm.trident.tuple.TridentTuple;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by judasheng on 14-12-12.
+ */
+public class RedisClusterStateSetCountQuerier extends BaseQueryFunction<RedisClusterState, Long> {
+    private static final Logger logger = LoggerFactory.getLogger(RedisClusterState.class);
+
+    private final String redisKeyPrefix;
+    private final TridentTupleMapper tupleMapper;
+
+    public RedisClusterStateSetCountQuerier(String redisKeyPrefix, TridentTupleMapper tupleMapper) {
+        this.redisKeyPrefix = redisKeyPrefix;
+        this.tupleMapper = tupleMapper;
+    }
+
+    @Override
+    public List<Long> batchRetrieve(RedisClusterState redisClusterState, List<TridentTuple> inputs) {
+        List<Long> ret = new ArrayList<Long>();
+        for(TridentTuple input: inputs) {
+            String key = this.tupleMapper.getKeyFromTridentTuple(input);
+            if (redisKeyPrefix != null && redisKeyPrefix.length() > 0) {
+                key = redisKeyPrefix + key;
+            }
+            long count = redisClusterState.scard(key);
+            ret.add(count);
+
+            logger.debug("RedisClusterStateSetCountQuerier key[" + key + "] count[" + count + "]");
+        }
+        return ret;
+    }
+
+    @Override
+    public void execute(TridentTuple tuple, Long s, TridentCollector collector) {
+        String key = this.tupleMapper.getKeyFromTridentTuple(tuple);
+        collector.emit(new Values(key, s));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/storm/blob/741a14c7/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateSetUpdater.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateSetUpdater.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateSetUpdater.java
new file mode 100644
index 0000000..a41ab64
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateSetUpdater.java
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident.state;
+
+import backtype.storm.tuple.Values;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import storm.trident.operation.TridentCollector;
+import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
+import storm.trident.state.BaseStateUpdater;
+import storm.trident.tuple.TridentTuple;
+
+import java.util.List;
+
+/**
+ * Created by judasheng on 14-12-12.
+ */
+public class RedisClusterStateSetUpdater extends BaseStateUpdater<RedisClusterState> {
+    private static final Logger logger = LoggerFactory.getLogger(RedisClusterState.class);
+
+    private static final long DEFAULT_EXPIRE_INTERVAL_MS = 86400000;
+
+    private final String redisKeyPrefix;
+    private final TridentTupleMapper tupleMapper;
+    private final long expireIntervalMs;
+
+    public RedisClusterStateSetUpdater(String redisKeyPrefix, TridentTupleMapper tupleMapper, long expireIntervalMs) {
+        this.redisKeyPrefix = redisKeyPrefix;
+        this.tupleMapper = tupleMapper;
+        if (expireIntervalMs > 0) {
+            this.expireIntervalMs = expireIntervalMs;
+        } else {
+            this.expireIntervalMs = DEFAULT_EXPIRE_INTERVAL_MS;
+        }
+    }
+
+    @Override
+    public void updateState(RedisClusterState redisClusterState, List<TridentTuple> inputs,
+                            TridentCollector collector) {
+        long expireAt = System.currentTimeMillis() + expireIntervalMs;
+        for (TridentTuple input : inputs) {
+            String key = this.tupleMapper.getKeyFromTridentTuple(input);
+            String redisKey = key;
+            if (redisKeyPrefix != null && redisKeyPrefix.length() > 0) {
+                redisKey = redisKeyPrefix + redisKey;
+            }
+            String value = this.tupleMapper.getValueFromTridentTuple(input);
+
+            logger.debug("RedisClusterStateSetUpdater key[" + key + "] redisKey[" + redisKey + "] value[" + value + "]");
+            redisClusterState.sadd(redisKey, value);
+            redisClusterState.expireAt(redisKey, expireAt);
+            Long count = redisClusterState.scard(redisKey);
+
+            collector.emit(new Values(key, count));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/741a14c7/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
new file mode 100644
index 0000000..049a663
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
@@ -0,0 +1,314 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident.state;
+
+import backtype.storm.task.IMetricsContext;
+import backtype.storm.tuple.Values;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.JedisPool;
+import redis.clients.jedis.JedisPoolConfig;
+import redis.clients.jedis.Pipeline;
+import redis.clients.jedis.Protocol;
+import storm.trident.state.JSONNonTransactionalSerializer;
+import storm.trident.state.JSONOpaqueSerializer;
+import storm.trident.state.JSONTransactionalSerializer;
+import storm.trident.state.OpaqueValue;
+import storm.trident.state.Serializer;
+import storm.trident.state.State;
+import storm.trident.state.StateFactory;
+import storm.trident.state.StateType;
+import storm.trident.state.TransactionalValue;
+import storm.trident.state.map.CachedMap;
+import storm.trident.state.map.IBackingMap;
+import storm.trident.state.map.MapState;
+import storm.trident.state.map.NonTransactionalMap;
+import storm.trident.state.map.OpaqueMap;
+import storm.trident.state.map.SnapshottableMap;
+import storm.trident.state.map.TransactionalMap;
+
+import java.io.Serializable;
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+
+public class RedisMapState<T> implements IBackingMap<T> {
+   private static final Logger logger = LoggerFactory.getLogger(RedisMapState.class);
+
+   private static final EnumMap<StateType, Serializer> DEFAULT_SERIALIZERS = Maps.newEnumMap(ImmutableMap.of(
+         StateType.NON_TRANSACTIONAL, new JSONNonTransactionalSerializer(),
+         StateType.TRANSACTIONAL, new JSONTransactionalSerializer(),
+         StateType.OPAQUE, new JSONOpaqueSerializer()
+   ));
+
+   public static class DefaultKeyFactory implements KeyFactory {
+      public String build(List<Object> key) {
+         if (key.size() != 1)
+            throw new RuntimeException("Default KeyFactory does not support compound keys");
+         return (String) key.get(0);
+      }
+   };
+
+   public static class Options<T> implements Serializable {
+      public int localCacheSize = 1000;
+      public String globalKey = "$REDIS-MAP-STATE-GLOBAL";
+      public Serializer<T> serializer = null;
+      public KeyFactory keyFactory = null;
+      public int connectionTimeout = Protocol.DEFAULT_TIMEOUT;
+      public String password = null;
+      public int database = Protocol.DEFAULT_DATABASE;
+      public String hkey = null;
+   }
+
+   public static interface KeyFactory extends Serializable {
+      String build(List<Object> key);
+   }
+
+   public static StateFactory opaque(InetSocketAddress server) {
+      return opaque(server, new Options());
+   }
+
+   public static StateFactory opaque(InetSocketAddress server, String hkey) {
+      Options opts = new Options();
+      opts.hkey = hkey;
+      return opaque(server, opts);
+   }
+
+   public static StateFactory opaque(InetSocketAddress server, Options<OpaqueValue> opts) {
+      return opaque(server, opts, new DefaultKeyFactory());
+   }
+
+   public static StateFactory opaque(InetSocketAddress server, Options<OpaqueValue> opts, KeyFactory factory) {
+      return new Factory(server, StateType.OPAQUE, opts, factory);
+   }
+
+   public static StateFactory transactional(InetSocketAddress server) {
+      return transactional(server, new Options());
+   }
+
+   public static StateFactory transactional(InetSocketAddress server, String hkey) {
+      Options opts = new Options();
+      opts.hkey = hkey;
+      return transactional(server, opts);
+   }
+
+   public static StateFactory transactional(InetSocketAddress server, Options<TransactionalValue> opts) {
+      return transactional(server, opts, new DefaultKeyFactory());
+   }
+
+   public static StateFactory transactional(InetSocketAddress server, Options<TransactionalValue> opts, KeyFactory factory) {
+      return new Factory(server, StateType.TRANSACTIONAL, opts, factory);
+   }
+
+   public static StateFactory nonTransactional(InetSocketAddress server) {
+      return nonTransactional(server, new Options());
+   }
+
+   public static StateFactory nonTransactional(InetSocketAddress server, String hkey) {
+      Options opts = new Options();
+      opts.hkey = hkey;
+      return nonTransactional(server, opts);
+   }
+
+   public static StateFactory nonTransactional(InetSocketAddress server, Options<Object> opts) {
+      return nonTransactional(server, opts, new DefaultKeyFactory());
+   }
+
+   public static StateFactory nonTransactional(InetSocketAddress server, Options<Object> opts, KeyFactory factory) {
+      return new Factory(server, StateType.NON_TRANSACTIONAL, opts, factory);
+   }
+
+   protected static class Factory implements StateFactory {
+      StateType type;
+      InetSocketAddress server;
+      Serializer serializer;
+      KeyFactory factory;
+      Options options;
+
+      public Factory(InetSocketAddress server, StateType type, Options options, KeyFactory factory) {
+         this.type = type;
+         this.server = server;
+         this.options = options;
+         this.factory = factory;
+
+         if (options.serializer == null) {
+            serializer = DEFAULT_SERIALIZERS.get(type);
+            if (serializer == null) {
+               throw new RuntimeException("Couldn't find serializer for state type: " + type);
+            }
+         } else {
+            this.serializer = options.serializer;
+         }
+      }
+
+      public State makeState(@SuppressWarnings("rawtypes") Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
+         JedisPool pool = new JedisPool(new JedisPoolConfig(),
+                    server.getHostName(), server.getPort(),
+                    options.connectionTimeout,
+                    options.password,
+                    options.database);
+         RedisMapState state = new RedisMapState(pool, options, serializer, factory);
+         CachedMap c = new CachedMap(state, options.localCacheSize);
+
+         MapState ms;
+         if (type == StateType.NON_TRANSACTIONAL) {
+            ms = NonTransactionalMap.build(c);
+
+         } else if (type == StateType.OPAQUE) {
+            ms = OpaqueMap.build(c);
+
+         } else if (type == StateType.TRANSACTIONAL) {
+            ms = TransactionalMap.build(c);
+
+         } else {
+            throw new RuntimeException("Unknown state type: " + type);
+         }
+
+         return new SnapshottableMap(ms, new Values(options.globalKey));
+      }
+   }
+
+   private final JedisPool pool;
+   private Options options;
+   private Serializer serializer;
+   private KeyFactory keyFactory;
+
+   public RedisMapState(JedisPool pool, Options options, Serializer<T> serializer, KeyFactory keyFactory) {
+      this.pool = pool;
+      this.options = options;
+      this.serializer = serializer;
+      this.keyFactory = keyFactory;
+   }
+
+   public List<T> multiGet(List<List<Object>> keys) {
+      if (keys.size() == 0) {
+         return Collections.emptyList();
+      }
+      if (Strings.isNullOrEmpty(this.options.hkey)) {
+         String[] stringKeys = buildKeys(keys);
+         List<String> values = mget(stringKeys);
+         return deserializeValues(keys, values);
+      } else {
+         Map<byte[], byte[]> keyValue = hgetAll(this.options.hkey.getBytes());
+         List<String> values = buildValuesFromMap(keys, keyValue);
+         return deserializeValues(keys, values);
+      }
+   }
+
+   private List<String> buildValuesFromMap(List<List<Object>> keys, Map<byte[], byte[]> keyValue) {
+      List<String> values = new ArrayList<String>(keys.size());
+      for (List<Object> key : keys) {
+         String strKey = keyFactory.build(key);
+         byte[] bytes = keyValue.get(strKey.getBytes());
+         values.add(new String(bytes));
+      }
+      return values;
+   }
+
+   private List<T> deserializeValues(List<List<Object>> keys, List<String> values) {
+      List<T> result = new ArrayList<T>(keys.size());
+      for (String value : values) {
+         if (value != null) {
+            result.add((T) serializer.deserialize(value.getBytes()));
+         } else {
+            result.add(null);
+         }
+      }
+      return result;
+   }
+
+   private String[] buildKeys(List<List<Object>> keys) {
+      String[] stringKeys = new String[keys.size()];
+      int index = 0;
+      for (List<Object> key : keys)
+         stringKeys[index++] = keyFactory.build(key);
+      return stringKeys;
+   }
+
+   private List<String> mget(String... keys) {
+      Jedis jedis = pool.getResource();
+      try {
+         return jedis.mget(keys);
+      } finally {
+         pool.returnResource(jedis);
+      }
+   }
+
+   private Map<byte[], byte[]> hgetAll(byte[] bytes) {
+      Jedis jedis = pool.getResource();
+      try {
+         return jedis.hgetAll(bytes);
+      } finally {
+         pool.returnResource(jedis);
+      }
+   }
+
+   public void multiPut(List<List<Object>> keys, List<T> vals) {
+      if (keys.size() == 0) {
+         return;
+      }
+
+      if (Strings.isNullOrEmpty(this.options.hkey)) {
+         String[] keyValues = buildKeyValuesList(keys, vals);
+         mset(keyValues);
+      } else {
+         Jedis jedis = pool.getResource();
+         try {
+            Pipeline pl = jedis.pipelined();
+            pl.multi();
+
+            for (int i = 0; i < keys.size(); i++) {
+               String val = new String(serializer.serialize(vals.get(i)));
+               pl.hset(this.options.hkey,
+                     keyFactory.build(keys.get(i)),
+                     val);
+            }
+
+            pl.exec();
+            pl.sync();
+         } finally {
+            pool.returnResource(jedis);
+         }
+      }
+   }
+
+   private String[] buildKeyValuesList(List<List<Object>> keys, List<T> vals) {
+      String[] keyValues = new String[keys.size() * 2];
+      for (int i = 0; i < keys.size(); i++) {
+         keyValues[i * 2] = keyFactory.build(keys.get(i));
+         keyValues[i * 2 + 1] = new String(serializer.serialize(vals.get(i)));
+      }
+      return keyValues;
+   }
+
+   private void mset(String... keyValues) {
+      Jedis jedis = pool.getResource();
+      try {
+         jedis.mset(keyValues);
+      } finally {
+         pool.returnResource(jedis);
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/741a14c7/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapStateExample.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapStateExample.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapStateExample.java
new file mode 100644
index 0000000..8fa784a
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapStateExample.java
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident.state;
+
+import backtype.storm.Config;
+import backtype.storm.LocalCluster;
+import backtype.storm.LocalDRPC;
+import backtype.storm.generated.StormTopology;
+import backtype.storm.tuple.Fields;
+import backtype.storm.tuple.Values;
+import backtype.storm.utils.Utils;
+import redis.clients.jedis.exceptions.JedisConnectionException;
+import storm.trident.TridentState;
+import storm.trident.TridentTopology;
+import storm.trident.operation.BaseFunction;
+import storm.trident.operation.TridentCollector;
+import storm.trident.operation.builtin.Count;
+import storm.trident.operation.builtin.FilterNull;
+import storm.trident.operation.builtin.MapGet;
+import storm.trident.operation.builtin.Sum;
+import storm.trident.state.StateFactory;
+import storm.trident.testing.FixedBatchSpout;
+import storm.trident.tuple.TridentTuple;
+
+import java.net.InetSocketAddress;
+
+public class RedisMapStateExample {
+
+	public static class Split extends BaseFunction {
+		@Override
+		public void execute(TridentTuple tuple, TridentCollector collector) {
+			String sentence = tuple.getString(0);
+			for (String word : sentence.split(" ")) {
+				collector.emit(new Values(word));
+			}
+		}
+	}
+
+	public static StormTopology buildTopology(LocalDRPC drpc, StateFactory state) {
+		FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 3,
+				new Values("the cow jumped over the moon"), 
+				new Values("the man went to the store and bought some candy"),
+				new Values("four score and seven years ago"), 
+				new Values("how many apples can you eat"), 
+				new Values("to be or not to be the person"));
+		spout.setCycle(true);
+
+		TridentTopology topology = new TridentTopology();
+		TridentState wordCounts = topology.newStream("spout1", spout)
+				.each(new Fields("sentence"), new Split(), new Fields("word"))
+				.groupBy(new Fields("word"))
+				.persistentAggregate(state, new Count(), new Fields("count"))
+				.parallelismHint(6);
+
+		topology.newDRPCStream("words", drpc)
+				.each(new Fields("args"), new Split(), new Fields("word"))
+				.groupBy(new Fields("word"))
+				.stateQuery(wordCounts, new Fields("word"), new MapGet(),
+						new Fields("count"))
+				.each(new Fields("count"), new FilterNull())
+				.aggregate(new Fields("count"), new Sum(), new Fields("sum"));
+
+		return topology.build();
+	}
+
+	public static void main(String[] args) {
+		StateFactory redis = RedisMapState.nonTransactional(new InetSocketAddress("localhost", 6379));
+
+		LocalDRPC drpc = new LocalDRPC();
+		StormTopology topology = buildTopology(drpc, redis);
+		Config conf = new Config();
+		LocalCluster cluster = new LocalCluster();
+		cluster.submitTopology("tester", conf, topology);
+
+		try {
+			for (int i = 0; i < 100; i++) {
+				System.out.println("DRPC: " + drpc.execute("words", "cat the man four"));
+				Utils.sleep(1000);
+			}
+			
+		} catch (JedisConnectionException e) {
+			throw new RuntimeException("Unfortunately, this test requires redis-server runing on localhost:6379", e);
+		}
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/741a14c7/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 5645b9a..5d5936d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -161,6 +161,7 @@
         <module>external/storm-kafka</module>
         <module>external/storm-hdfs</module>
         <module>external/storm-hbase</module>
+        <module>external/storm-redis</module>
     </modules>
 
     <scm>


[16/23] storm git commit: change set to setex and pipeline to hmset

Posted by bo...@apache.org.
change set to setex and pipeline to hmset


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

Branch: refs/heads/master
Commit: 3cee80fc12ca5cdab5a200ac52d67ca55e1a1c69
Parents: b1a3396
Author: dashengju <da...@qq.com>
Authored: Mon Jan 5 18:47:25 2015 +0800
Committer: dashengju <da...@qq.com>
Committed: Mon Jan 5 18:47:25 2015 +0800

----------------------------------------------------------------------
 .../trident/state/RedisClusterMapState.java     |  6 ++++--
 .../trident/state/RedisClusterStateQuerier.java |  3 ---
 .../trident/state/RedisClusterStateUpdater.java | 20 +++++++++----------
 .../redis/trident/state/RedisMapState.java      | 13 +++++-------
 .../trident/state/RedisStateSetUpdater.java     | 20 +++++++++----------
 .../redis/trident/state/RedisStateUpdater.java  | 21 ++++++++++----------
 6 files changed, 39 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/3cee80fc/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 6324126..04e5723 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
@@ -48,6 +48,7 @@ import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.EnumMap;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -283,11 +284,12 @@ public class RedisClusterMapState<T> implements IBackingMap<T> {
                 jedisCluster.set(redisKey, val);
             }
         } else {
+            Map<String, String> keyValues = new HashMap<String, String>();
             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.hset(this.options.hkey, redisKey, val);
+                keyValues.put(keyFactory.build(keys.get(i)), val);
             }
+            jedisCluster.hmset(this.options.hkey, keyValues);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/storm/blob/3cee80fc/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateQuerier.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateQuerier.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateQuerier.java
index 3dc31d2..e0207e2 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateQuerier.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateQuerier.java
@@ -29,9 +29,6 @@ import storm.trident.tuple.TridentTuple;
 
 import java.util.List;
 
-/**
- * Created by judasheng on 14-12-12.
- */
 public class RedisClusterStateQuerier extends BaseQueryFunction<RedisClusterState, String> {
     private static final Logger logger = LoggerFactory.getLogger(RedisClusterState.class);
 

http://git-wip-us.apache.org/repos/asf/storm/blob/3cee80fc/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateUpdater.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateUpdater.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateUpdater.java
index 8215b7f..e72735a 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateUpdater.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateUpdater.java
@@ -30,26 +30,23 @@ import java.util.List;
 public class RedisClusterStateUpdater extends BaseStateUpdater<RedisClusterState> {
     private static final Logger logger = LoggerFactory.getLogger(RedisClusterState.class);
 
-    private static final long DEFAULT_EXPIRE_INTERVAL_MS = 86400000;
-
     private final String redisKeyPrefix;
     private final TridentTupleMapper tupleMapper;
-    private final long expireIntervalMs;
+    private final int expireIntervalSec;
 
-    public RedisClusterStateUpdater(String redisKeyPrefix, TridentTupleMapper tupleMapper, long expireIntervalMs) {
+    public RedisClusterStateUpdater(String redisKeyPrefix, TridentTupleMapper tupleMapper, int expireIntervalSec) {
         this.redisKeyPrefix = redisKeyPrefix;
         this.tupleMapper = tupleMapper;
-        if (expireIntervalMs > 0) {
-            this.expireIntervalMs = expireIntervalMs;
+        if (expireIntervalSec > 0) {
+            this.expireIntervalSec = expireIntervalSec;
         } else {
-            this.expireIntervalMs = DEFAULT_EXPIRE_INTERVAL_MS;
+            this.expireIntervalSec = 0;
         }
     }
 
     @Override
     public void updateState(RedisClusterState redisClusterState, List<TridentTuple> inputs,
                             TridentCollector collector) {
-        long expireAt = System.currentTimeMillis() + expireIntervalMs;
 
         JedisCluster jedisCluster = null;
         try {
@@ -64,8 +61,11 @@ public class RedisClusterStateUpdater extends BaseStateUpdater<RedisClusterState
 
                 logger.debug("update key[" + key + "] redisKey[" + redisKey + "] value[" + value + "]");
 
-                jedisCluster.set(redisKey, value);
-                jedisCluster.expireAt(redisKey, expireAt);
+                if (this.expireIntervalSec > 0) {
+                    jedisCluster.setex(redisKey, expireIntervalSec, value);
+                } else {
+                    jedisCluster.set(redisKey, value);
+                }
             }
         } finally {
             if (jedisCluster != null) {

http://git-wip-us.apache.org/repos/asf/storm/blob/3cee80fc/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
index bb9fa9d..1a5cc7c 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
@@ -27,7 +27,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import redis.clients.jedis.Jedis;
 import redis.clients.jedis.JedisPool;
-import redis.clients.jedis.Pipeline;
 import storm.trident.state.JSONNonTransactionalSerializer;
 import storm.trident.state.JSONOpaqueSerializer;
 import storm.trident.state.JSONTransactionalSerializer;
@@ -49,6 +48,7 @@ import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.EnumMap;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -300,16 +300,13 @@ public class RedisMapState<T> implements IBackingMap<T> {
         } else {
             Jedis jedis = jedisPool.getResource();
             try {
-                Pipeline pl = jedis.pipelined();
-                pl.multi();
-
+                Map<String, String> keyValues = new HashMap<String, String>();
                 for (int i = 0; i < keys.size(); i++) {
                     String val = new String(serializer.serialize(vals.get(i)));
-                    pl.hset(this.options.hkey, keyFactory.build(keys.get(i)), val);
-                }
+                    keyValues.put(keyFactory.build(keys.get(i)), val);
+                }               
+                jedis.hmset(this.options.hkey, keyValues);
 
-                pl.exec();
-                pl.sync();
             } finally {
                 jedisPool.returnResource(jedis);
             }

http://git-wip-us.apache.org/repos/asf/storm/blob/3cee80fc/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java
index 2134d99..c36d1f0 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java
@@ -31,26 +31,23 @@ import java.util.List;
 public class RedisStateSetUpdater extends BaseStateUpdater<RedisState> {
     private static final Logger logger = LoggerFactory.getLogger(RedisState.class);
 
-    private static final long DEFAULT_EXPIRE_INTERVAL_MS = 86400000;
-
     private final String redisKeyPrefix;
     private final TridentTupleMapper tupleMapper;
-    private final long expireIntervalMs;
+    private final int expireIntervalSec;
 
-    public RedisStateSetUpdater(String redisKeyPrefix, TridentTupleMapper tupleMapper, long expireIntervalMs) {
+    public RedisStateSetUpdater(String redisKeyPrefix, TridentTupleMapper tupleMapper, int expireIntervalSec) {
         this.redisKeyPrefix = redisKeyPrefix;
         this.tupleMapper = tupleMapper;
-        if (expireIntervalMs > 0) {
-            this.expireIntervalMs = expireIntervalMs;
+        if (expireIntervalSec > 0) {
+            this.expireIntervalSec = expireIntervalSec;
         } else {
-            this.expireIntervalMs = DEFAULT_EXPIRE_INTERVAL_MS;
+            this.expireIntervalSec = 0;
         }
     }
 
     @Override
     public void updateState(RedisState redisState, List<TridentTuple> inputs,
                             TridentCollector collector) {
-        long expireAt = System.currentTimeMillis() + expireIntervalMs;
 
         Jedis jedis = null;
         try {
@@ -65,8 +62,11 @@ public class RedisStateSetUpdater extends BaseStateUpdater<RedisState> {
 
                 logger.debug("update key[" + key + "] redisKey[" + redisKey + "] value[" + value + "]");
 
-                jedis.sadd(redisKey, value);
-                jedis.expireAt(redisKey, expireAt);
+                if (this.expireIntervalSec > 0) {
+                    jedis.setex(redisKey, expireIntervalSec, value);
+                } else {
+                    jedis.set(redisKey, value);
+                }
                 Long count = jedis.scard(redisKey);
 
                 collector.emit(new Values(key, count));

http://git-wip-us.apache.org/repos/asf/storm/blob/3cee80fc/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java
index 6fdede5..67f7c51 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java
@@ -30,27 +30,23 @@ import java.util.List;
 public class RedisStateUpdater extends BaseStateUpdater<RedisState> {
     private static final Logger logger = LoggerFactory.getLogger(RedisState.class);
 
-    private static final long DEFAULT_EXPIRE_INTERVAL_MS = 86400000;
-
     private final String redisKeyPrefix;
     private final TridentTupleMapper tupleMapper;
-    private final long expireIntervalMs;
+    private final int expireIntervalSec;
 
-    public RedisStateUpdater(String redisKeyPrefix, TridentTupleMapper tupleMapper, long expireIntervalMs) {
+    public RedisStateUpdater(String redisKeyPrefix, TridentTupleMapper tupleMapper, int expireIntervalSec) {
         this.redisKeyPrefix = redisKeyPrefix;
         this.tupleMapper = tupleMapper;
-        if (expireIntervalMs > 0) {
-            this.expireIntervalMs = expireIntervalMs;
+        if (expireIntervalSec > 0) {
+            this.expireIntervalSec = expireIntervalSec;
         } else {
-            this.expireIntervalMs = DEFAULT_EXPIRE_INTERVAL_MS;
+            this.expireIntervalSec = 0;
         }
     }
 
     @Override
     public void updateState(RedisState redisState, List<TridentTuple> inputs,
                             TridentCollector collector) {
-        long expireAt = System.currentTimeMillis() + expireIntervalMs;
-
         Jedis jedis = null;
         try {
             jedis = redisState.getJedis();
@@ -64,8 +60,11 @@ public class RedisStateUpdater extends BaseStateUpdater<RedisState> {
 
                 logger.debug("update key[" + key + "] redisKey[" + redisKey + "] value[" + value + "]");
 
-                jedis.set(redisKey, value);
-                jedis.expireAt(redisKey, expireAt);
+                if (this.expireIntervalSec > 0) {
+                    jedis.setex(redisKey, expireIntervalSec, value);
+                } else {
+                    jedis.set(redisKey, value);
+                }
             }
         } finally {
             if (jedis != null) {


[03/23] storm git commit: Remove invalid exclusion

Posted by bo...@apache.org.
Remove invalid exclusion


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

Branch: refs/heads/master
Commit: 28ebb82d3a1e5364fef8f63775ac2341b991a5aa
Parents: 5c357ff
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Tue Dec 30 10:22:27 2014 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Tue Dec 30 10:22:27 2014 +0900

----------------------------------------------------------------------
 external/storm-redis/pom.xml | 10 ----------
 1 file changed, 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/28ebb82d/external/storm-redis/pom.xml
----------------------------------------------------------------------
diff --git a/external/storm-redis/pom.xml b/external/storm-redis/pom.xml
index 1f23e90..3f89ffc 100644
--- a/external/storm-redis/pom.xml
+++ b/external/storm-redis/pom.xml
@@ -50,16 +50,6 @@
             <groupId>redis.clients</groupId>
             <artifactId>jedis</artifactId>
             <version>${jedis.version}</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.slf4j</groupId>
-                    <artifactId>slf4j-log4j12</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.zookeeper</groupId>
-                    <artifactId>zookeeper</artifactId>
-                </exclusion>
-            </exclusions>
         </dependency>
     </dependencies>
 </project>


[02/23] storm git commit: Change Readme

Posted by bo...@apache.org.
Change Readme


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

Branch: refs/heads/master
Commit: 5c357ffe7381d0d608e04826ac6b4d915aa2fb72
Parents: 741a14c
Author: dashengju <da...@qq.com>
Authored: Fri Dec 26 13:58:18 2014 +0800
Committer: dashengju <da...@qq.com>
Committed: Fri Dec 26 13:58:18 2014 +0800

----------------------------------------------------------------------
 external/storm-redis/README.md | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/5c357ffe/external/storm-redis/README.md
----------------------------------------------------------------------
diff --git a/external/storm-redis/README.md b/external/storm-redis/README.md
index 3f5fa55..dc68224 100644
--- a/external/storm-redis/README.md
+++ b/external/storm-redis/README.md
@@ -6,31 +6,14 @@ Storm/Trident integration for [Redis](http://redis.io/)
 
 ### How do I use it?
 
-You can download the latest build at:
-    http://github.com/dashengju/storm-redis/releases
-
-Or use it as a maven dependency:
-
-```xml
-<repositories>
-    <repository>
-        <id>storm-redis</id>
-        <url>https://raw.github.com/dashengju/storm-redis/mvn-repo/</url>
-        <snapshots>
-            <enabled>true</enabled>
-            <updatePolicy>always</updatePolicy>
-        </snapshots>
-    </repository>
-</repositories>
-```
+use it as a maven dependency:
 
 ```xml
 <dependency>
     <groupId>org.apache.storm</groupId>
     <artifactId>storm-redis</artifactId>
-    <version>1.0.1</version>
+    <version>0.10.0</version>
     <type>jar</type>
-    <scope>compile</scope>
 </dependency>
 ```
 


[23/23] storm git commit: Added STORM-609 to Changelog

Posted by bo...@apache.org.
Added STORM-609 to Changelog


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

Branch: refs/heads/master
Commit: 4b6e43b815a2f1f48bb04b24b2acfc4cad4d480d
Parents: 240eb7c
Author: Robert (Bobby) Evans <ev...@yahoo-inc.com>
Authored: Mon Feb 23 10:25:38 2015 -0600
Committer: Robert (Bobby) Evans <ev...@yahoo-inc.com>
Committed: Mon Feb 23 10:25:38 2015 -0600

----------------------------------------------------------------------
 CHANGELOG.md | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/4b6e43b8/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 31cd79f..63f1594 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -52,6 +52,7 @@
  * STORM-400: Thrift upgrade to thrift-0.9.2
  * STORM-673: Typo 'deamon' in security documentation
  * STORM-441: Remove bootstrap macro from Clojure codebase
+ * STORM-609: Add storm-redis to storm external
 
 ## 0.9.3-rc2
  * STORM-558: change "swap!" to "reset!" to fix assignment-versions in supervisor


[19/23] storm git commit: add Bobby Evans to Committer Sponsors

Posted by bo...@apache.org.
add Bobby Evans to Committer Sponsors


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

Branch: refs/heads/master
Commit: dad3b80f938616f810d29b1a147e24faba765d22
Parents: 3356c86
Author: dashengju <da...@qq.com>
Authored: Wed Jan 21 10:50:22 2015 +0800
Committer: dashengju <da...@qq.com>
Committed: Wed Jan 21 10:50:22 2015 +0800

----------------------------------------------------------------------
 external/storm-redis/README.md | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/dad3b80f/external/storm-redis/README.md
----------------------------------------------------------------------
diff --git a/external/storm-redis/README.md b/external/storm-redis/README.md
index 17f74db..3dc030d 100644
--- a/external/storm-redis/README.md
+++ b/external/storm-redis/README.md
@@ -134,6 +134,7 @@ under the License.
 
 ## Committer Sponsors
 
+ * Bobby Evans ([bobby@apache.org](mailto:bobby@apache.org))
  * DashengJu ([dashengju@gmail.com](mailto:dashengju@gmail.com))
  * HeartSaVioR ([kabhwan@gmail.com](mailto:kabhwan@gmail.com))
  


[11/23] storm git commit: change storm-redis trident state implements

Posted by bo...@apache.org.
change storm-redis trident state implements


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

Branch: refs/heads/master
Commit: 0f9438fc5491fb3764849b31536352e69deae8ea
Parents: ff36ac8
Author: dashengju <da...@qq.com>
Authored: Sun Jan 4 16:31:40 2015 +0800
Committer: dashengju <da...@qq.com>
Committed: Sun Jan 4 16:31:40 2015 +0800

----------------------------------------------------------------------
 .../trident/state/RedisClusterMapState.java     | 293 +++++++++++++++++++
 .../redis/trident/state/RedisClusterState.java  |  81 +++++
 .../trident/state/RedisClusterStateQuerier.java |  81 +++++
 .../trident/state/RedisClusterStateUpdater.java |  76 +++++
 .../redis/trident/state/RedisMapState.java      | 192 +++---------
 .../storm/redis/trident/state/RedisState.java   |  48 ++-
 .../redis/trident/state/RedisStateQuerier.java  |  35 +--
 .../state/RedisStateSetCountQuerier.java        |  12 +-
 .../trident/state/RedisStateSetUpdater.java     |  16 +-
 .../redis/trident/state/RedisStateUpdater.java  |  14 +-
 .../trident/WordCountTridentRedisCluster.java   |  13 +-
 .../WordCountTridentRedisClusterMap.java        | 101 +++++++
 12 files changed, 735 insertions(+), 227 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/0f9438fc/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
new file mode 100644
index 0000000..6324126
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterMapState.java
@@ -0,0 +1,293 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident.state;
+
+import backtype.storm.task.IMetricsContext;
+import backtype.storm.tuple.Values;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.apache.storm.redis.util.config.JedisClusterConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import redis.clients.jedis.JedisCluster;
+import storm.trident.state.JSONNonTransactionalSerializer;
+import storm.trident.state.JSONOpaqueSerializer;
+import storm.trident.state.JSONTransactionalSerializer;
+import storm.trident.state.OpaqueValue;
+import storm.trident.state.Serializer;
+import storm.trident.state.State;
+import storm.trident.state.StateFactory;
+import storm.trident.state.StateType;
+import storm.trident.state.TransactionalValue;
+import storm.trident.state.map.CachedMap;
+import storm.trident.state.map.IBackingMap;
+import storm.trident.state.map.MapState;
+import storm.trident.state.map.NonTransactionalMap;
+import storm.trident.state.map.OpaqueMap;
+import storm.trident.state.map.SnapshottableMap;
+import storm.trident.state.map.TransactionalMap;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+
+public class RedisClusterMapState<T> implements IBackingMap<T> {
+    private static final Logger logger = LoggerFactory.getLogger(RedisClusterMapState.class);
+
+    private static final EnumMap<StateType, Serializer> DEFAULT_SERIALIZERS = Maps.newEnumMap(ImmutableMap.of(
+            StateType.NON_TRANSACTIONAL, new JSONNonTransactionalSerializer(),
+            StateType.TRANSACTIONAL, new JSONTransactionalSerializer(),
+            StateType.OPAQUE, new JSONOpaqueSerializer()
+    ));
+
+    public static class DefaultKeyFactory implements KeyFactory {
+        public String build(List<Object> key) {
+            if (key.size() != 1)
+                throw new RuntimeException("Default KeyFactory does not support compound keys");
+            return (String) key.get(0);
+        }
+    };
+
+    public static class Options<T> implements Serializable {
+        public int localCacheSize = 1000;
+        public String globalKey = "$REDIS-MAP-STATE-GLOBAL";
+        KeyFactory keyFactory = null;
+        public Serializer<T> serializer = null;
+        public String hkey = null;
+    }
+
+    public static interface KeyFactory extends Serializable {
+        String build(List<Object> key);
+    }
+
+    /**
+     * OpaqueTransactional for redis-cluster.
+     * */
+    public static StateFactory opaque(JedisClusterConfig jedisClusterConfig) {
+        return opaque(jedisClusterConfig, new Options());
+    }
+
+    public static StateFactory opaque(JedisClusterConfig jedisClusterConfig, String hkey) {
+        Options opts = new Options();
+        opts.hkey = hkey;
+        return opaque(jedisClusterConfig, opts);
+    }
+
+    public static StateFactory opaque(JedisClusterConfig jedisClusterConfig, KeyFactory factory) {
+        Options opts = new Options();
+        opts.keyFactory = factory;
+        return opaque(jedisClusterConfig, opts);
+    }
+
+    public static StateFactory opaque(JedisClusterConfig jedisClusterConfig, Options<OpaqueValue> opts) {
+        return new Factory(jedisClusterConfig, StateType.OPAQUE, opts);
+    }
+
+    /**
+     * Transactional for redis-cluster.
+     * */
+    public static StateFactory transactional(JedisClusterConfig jedisClusterConfig) {
+        return transactional(jedisClusterConfig, new Options());
+    }
+
+    public static StateFactory transactional(JedisClusterConfig jedisClusterConfig, String hkey) {
+        Options opts = new Options();
+        opts.hkey = hkey;
+        return transactional(jedisClusterConfig, opts);
+    }
+
+    public static StateFactory transactional(JedisClusterConfig jedisClusterConfig, KeyFactory factory) {
+        Options opts = new Options();
+        opts.keyFactory = factory;
+        return transactional(jedisClusterConfig, opts);
+    }
+
+    public static StateFactory transactional(JedisClusterConfig jedisClusterConfig, Options<TransactionalValue> opts) {
+        return new Factory(jedisClusterConfig, StateType.TRANSACTIONAL, opts);
+    }
+
+    /**
+     * NonTransactional for redis-cluster.
+     * */
+    public static StateFactory nonTransactional(JedisClusterConfig jedisClusterConfig) {
+        return nonTransactional(jedisClusterConfig, new Options());
+    }
+
+    public static StateFactory nonTransactional(JedisClusterConfig jedisClusterConfig, String hkey) {
+        Options opts = new Options();
+        opts.hkey = hkey;
+        return nonTransactional(jedisClusterConfig, opts);
+    }
+
+    public static StateFactory nonTransactional(JedisClusterConfig jedisClusterConfig, KeyFactory factory) {
+        Options opts = new Options();
+        opts.keyFactory = factory;
+        return nonTransactional(jedisClusterConfig, opts);
+    }
+
+    public static StateFactory nonTransactional(JedisClusterConfig jedisClusterConfig, Options<Object> opts) {
+        return new Factory(jedisClusterConfig, StateType.NON_TRANSACTIONAL, opts);
+    }
+
+
+
+    protected static class Factory implements StateFactory {
+        // TODO : serialize redis.clients.jedis.JedisPoolConfig
+        public static final redis.clients.jedis.JedisPoolConfig DEFAULT_POOL_CONFIG = new redis.clients.jedis.JedisPoolConfig();
+
+        JedisClusterConfig jedisClusterConfig;
+
+        StateType type;
+        Serializer serializer;
+        KeyFactory keyFactory;
+        Options options;
+
+        public Factory(JedisClusterConfig jedisClusterConfig, StateType type, Options options) {
+            this.jedisClusterConfig = jedisClusterConfig;
+            this.type = type;
+            this.options = options;
+
+            this.keyFactory = options.keyFactory;
+            if (this.keyFactory == null) {
+                this.keyFactory = new DefaultKeyFactory();
+            }
+            this.serializer = options.serializer;
+            if (this.serializer == null) {
+                this.serializer = DEFAULT_SERIALIZERS.get(type);
+                if (this.serializer == null) {
+                    throw new RuntimeException("Couldn't find serializer for state type: " + type);
+                }
+            }
+        }
+
+        public State makeState(@SuppressWarnings("rawtypes") Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
+            JedisCluster jedisCluster = new JedisCluster(jedisClusterConfig.getNodes(),
+                                                            jedisClusterConfig.getTimeout(),
+                                                            jedisClusterConfig.getMaxRedirections(),
+                                                            DEFAULT_POOL_CONFIG);
+
+            RedisClusterMapState state = new RedisClusterMapState(jedisCluster, options, serializer, keyFactory);
+            CachedMap c = new CachedMap(state, options.localCacheSize);
+
+            MapState ms;
+            if (type == StateType.NON_TRANSACTIONAL) {
+                ms = NonTransactionalMap.build(c);
+
+            } else if (type == StateType.OPAQUE) {
+                ms = OpaqueMap.build(c);
+
+            } else if (type == StateType.TRANSACTIONAL) {
+                ms = TransactionalMap.build(c);
+
+            } else {
+                throw new RuntimeException("Unknown state type: " + type);
+            }
+
+            return new SnapshottableMap(ms, new Values(options.globalKey));
+        }
+    }
+
+    private JedisCluster jedisCluster;
+    private Options options;
+    private Serializer serializer;
+    private KeyFactory keyFactory;
+
+    public RedisClusterMapState(JedisCluster jedisCluster, Options options,
+                                Serializer<T> serializer, KeyFactory keyFactory) {
+        this.jedisCluster = jedisCluster;
+        this.options = options;
+        this.serializer = serializer;
+        this.keyFactory = keyFactory;
+    }
+
+    public List<T> multiGet(List<List<Object>> keys) {
+        if (keys.size() == 0) {
+            return Collections.emptyList();
+        }
+        if (Strings.isNullOrEmpty(this.options.hkey)) {
+            String[] stringKeys = buildKeys(keys);
+            List<String> values = Lists.newArrayList();
+
+            for (String stringKey : stringKeys) {
+                String value = jedisCluster.get(stringKey);
+                values.add(value);
+            }
+
+            return deserializeValues(keys, values);
+        } else {
+            Map<String, String> keyValue = jedisCluster.hgetAll(this.options.hkey);
+            List<String> values = buildValuesFromMap(keys, keyValue);
+            return deserializeValues(keys, values);
+        }
+    }
+
+    private List<String> buildValuesFromMap(List<List<Object>> keys, Map<String, String> keyValue) {
+        List<String> values = new ArrayList<String>(keys.size());
+        for (List<Object> key : keys) {
+            String strKey = keyFactory.build(key);
+            String value = keyValue.get(strKey);
+            values.add(value);
+        }
+        return values;
+    }
+
+    private List<T> deserializeValues(List<List<Object>> keys, List<String> values) {
+        List<T> result = new ArrayList<T>(keys.size());
+        for (String value : values) {
+            if (value != null) {
+                result.add((T) serializer.deserialize(value.getBytes()));
+            } else {
+                result.add(null);
+            }
+        }
+        return result;
+    }
+
+    private String[] buildKeys(List<List<Object>> keys) {
+        String[] stringKeys = new String[keys.size()];
+        int index = 0;
+        for (List<Object> key : keys)
+            stringKeys[index++] = keyFactory.build(key);
+        return stringKeys;
+    }
+
+    public void multiPut(List<List<Object>> keys, List<T> vals) {
+        if (keys.size() == 0) {
+            return;
+        }
+
+        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);
+            }
+        } else {
+            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.hset(this.options.hkey, redisKey, val);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/0f9438fc/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
new file mode 100644
index 0000000..8516bca
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterState.java
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident.state;
+
+import backtype.storm.task.IMetricsContext;
+import org.apache.storm.redis.util.config.JedisClusterConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import redis.clients.jedis.JedisCluster;
+import storm.trident.state.State;
+import storm.trident.state.StateFactory;
+
+import java.util.Map;
+
+public class RedisClusterState implements State {
+    private static final Logger logger = LoggerFactory.getLogger(RedisClusterState.class);
+
+    @Override
+    public void beginCommit(Long aLong) {
+    }
+
+    @Override
+    public void commit(Long aLong) {
+    }
+
+    public static class Factory implements StateFactory {
+        // TODO : serialize redis.clients.jedis.JedisPoolConfig
+        public static final redis.clients.jedis.JedisPoolConfig DEFAULT_POOL_CONFIG = new redis.clients.jedis.JedisPoolConfig();
+
+        private JedisClusterConfig jedisClusterConfig;
+
+        public Factory(JedisClusterConfig config) {
+            this.jedisClusterConfig = config;
+        }
+
+        public State makeState(@SuppressWarnings("rawtypes") Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
+            JedisCluster jedisCluster = new JedisCluster(jedisClusterConfig.getNodes(),
+                                                    jedisClusterConfig.getTimeout(),
+                                                    jedisClusterConfig.getMaxRedirections(),
+                                                    DEFAULT_POOL_CONFIG);
+
+            return new RedisClusterState(jedisCluster);
+        }
+    }
+
+    private JedisCluster jedisCluster;
+
+    public RedisClusterState(JedisCluster jedisCluster) {
+        this.jedisCluster = jedisCluster;
+    }
+
+    /**
+     * The state updater and querier can get a JedisCluster instance
+     * */
+    public JedisCluster getJedisCluster() {
+        return this.jedisCluster;
+    }
+
+    /**
+     * The state updater and querier return the JedisCluster instance
+     * */
+    public void returnJedisCluster(JedisCluster jedisCluster) {
+        //do nothing
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/0f9438fc/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateQuerier.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateQuerier.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateQuerier.java
new file mode 100644
index 0000000..3dc31d2
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateQuerier.java
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident.state;
+
+import backtype.storm.tuple.Values;
+import com.google.common.collect.Lists;
+import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import redis.clients.jedis.JedisCluster;
+import storm.trident.operation.TridentCollector;
+import storm.trident.state.BaseQueryFunction;
+import storm.trident.tuple.TridentTuple;
+
+import java.util.List;
+
+/**
+ * Created by judasheng on 14-12-12.
+ */
+public class RedisClusterStateQuerier extends BaseQueryFunction<RedisClusterState, String> {
+    private static final Logger logger = LoggerFactory.getLogger(RedisClusterState.class);
+
+    private final String redisKeyPrefix;
+    private final TridentTupleMapper tupleMapper;
+
+    public RedisClusterStateQuerier(String redisKeyPrefix, TridentTupleMapper tupleMapper) {
+        this.redisKeyPrefix = redisKeyPrefix;
+        this.tupleMapper = tupleMapper;
+    }
+
+    @Override
+    public List<String> batchRetrieve(RedisClusterState redisClusterState, List<TridentTuple> inputs) {
+        List<String> ret = Lists.newArrayList();
+
+        List<String> keys = Lists.newArrayList();
+
+        JedisCluster jedisCluster = null;
+        try {
+            jedisCluster = redisClusterState.getJedisCluster();
+
+
+            for (TridentTuple input : inputs) {
+                String key = this.tupleMapper.getKeyFromTridentTuple(input);
+                if (redisKeyPrefix != null && redisKeyPrefix.length() > 0) {
+                    key = redisKeyPrefix + key;
+                }
+                String value = jedisCluster.get(key);
+                ret.add(value);
+
+                logger.debug("redis get key[" + key + "] count[" + value + "]");
+            }
+        } finally {
+            if (jedisCluster != null) {
+                redisClusterState.returnJedisCluster(jedisCluster);
+            }
+        }
+
+        return ret;
+    }
+
+    @Override
+    public void execute(TridentTuple tuple, String s, TridentCollector collector) {
+        String key = this.tupleMapper.getKeyFromTridentTuple(tuple);
+        collector.emit(new Values(key, s));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/storm/blob/0f9438fc/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateUpdater.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateUpdater.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateUpdater.java
new file mode 100644
index 0000000..8215b7f
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateUpdater.java
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident.state;
+
+import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import redis.clients.jedis.JedisCluster;
+import storm.trident.operation.TridentCollector;
+import storm.trident.state.BaseStateUpdater;
+import storm.trident.tuple.TridentTuple;
+
+import java.util.List;
+
+public class RedisClusterStateUpdater extends BaseStateUpdater<RedisClusterState> {
+    private static final Logger logger = LoggerFactory.getLogger(RedisClusterState.class);
+
+    private static final long DEFAULT_EXPIRE_INTERVAL_MS = 86400000;
+
+    private final String redisKeyPrefix;
+    private final TridentTupleMapper tupleMapper;
+    private final long expireIntervalMs;
+
+    public RedisClusterStateUpdater(String redisKeyPrefix, TridentTupleMapper tupleMapper, long expireIntervalMs) {
+        this.redisKeyPrefix = redisKeyPrefix;
+        this.tupleMapper = tupleMapper;
+        if (expireIntervalMs > 0) {
+            this.expireIntervalMs = expireIntervalMs;
+        } else {
+            this.expireIntervalMs = DEFAULT_EXPIRE_INTERVAL_MS;
+        }
+    }
+
+    @Override
+    public void updateState(RedisClusterState redisClusterState, List<TridentTuple> inputs,
+                            TridentCollector collector) {
+        long expireAt = System.currentTimeMillis() + expireIntervalMs;
+
+        JedisCluster jedisCluster = null;
+        try {
+            jedisCluster = redisClusterState.getJedisCluster();
+            for (TridentTuple input : inputs) {
+                String key = this.tupleMapper.getKeyFromTridentTuple(input);
+                String redisKey = key;
+                if (redisKeyPrefix != null && redisKeyPrefix.length() > 0) {
+                    redisKey = redisKeyPrefix + redisKey;
+                }
+                String value = this.tupleMapper.getValueFromTridentTuple(input);
+
+                logger.debug("update key[" + key + "] redisKey[" + redisKey + "] value[" + value + "]");
+
+                jedisCluster.set(redisKey, value);
+                jedisCluster.expireAt(redisKey, expireAt);
+            }
+        } finally {
+            if (jedisCluster != null) {
+                redisClusterState.returnJedisCluster(jedisCluster);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/0f9438fc/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
index 7aa9dc9..bb9fa9d 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
@@ -21,16 +21,13 @@ import backtype.storm.task.IMetricsContext;
 import backtype.storm.tuple.Values;
 import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
-import org.apache.storm.redis.util.config.JedisClusterConfig;
 import org.apache.storm.redis.util.config.JedisPoolConfig;
-import org.apache.storm.redis.util.container.JedisCommandsContainerBuilder;
-import org.apache.storm.redis.util.container.JedisCommandsInstanceContainer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import redis.clients.jedis.Jedis;
-import redis.clients.jedis.JedisCommands;
+import redis.clients.jedis.JedisPool;
+import redis.clients.jedis.Pipeline;
 import storm.trident.state.JSONNonTransactionalSerializer;
 import storm.trident.state.JSONOpaqueSerializer;
 import storm.trident.state.JSONTransactionalSerializer;
@@ -108,29 +105,6 @@ public class RedisMapState<T> implements IBackingMap<T> {
     }
 
     /**
-     * OpaqueTransactional for redis-cluster.
-     * */
-    public static StateFactory opaque(JedisClusterConfig jedisClusterConfig) {
-        return opaque(jedisClusterConfig, new Options());
-    }
-
-    public static StateFactory opaque(JedisClusterConfig jedisClusterConfig, String hkey) {
-        Options opts = new Options();
-        opts.hkey = hkey;
-        return opaque(jedisClusterConfig, opts);
-    }
-
-    public static StateFactory opaque(JedisClusterConfig jedisClusterConfig, KeyFactory factory) {
-        Options opts = new Options();
-        opts.keyFactory = factory;
-        return opaque(jedisClusterConfig, opts);
-    }
-
-    public static StateFactory opaque(JedisClusterConfig jedisClusterConfig, Options<OpaqueValue> opts) {
-        return new Factory(jedisClusterConfig, StateType.OPAQUE, opts);
-    }
-
-    /**
      * Transactional for redis.
      * */
     public static StateFactory transactional(JedisPoolConfig jedisPoolConfig) {
@@ -154,29 +128,6 @@ public class RedisMapState<T> implements IBackingMap<T> {
     }
 
     /**
-     * Transactional for redis-cluster.
-     * */
-    public static StateFactory transactional(JedisClusterConfig jedisClusterConfig) {
-        return transactional(jedisClusterConfig, new Options());
-    }
-
-    public static StateFactory transactional(JedisClusterConfig jedisClusterConfig, String hkey) {
-        Options opts = new Options();
-        opts.hkey = hkey;
-        return transactional(jedisClusterConfig, opts);
-    }
-
-    public static StateFactory transactional(JedisClusterConfig jedisClusterConfig, KeyFactory factory) {
-        Options opts = new Options();
-        opts.keyFactory = factory;
-        return transactional(jedisClusterConfig, opts);
-    }
-
-    public static StateFactory transactional(JedisClusterConfig jedisClusterConfig, Options<TransactionalValue> opts) {
-        return new Factory(jedisClusterConfig, StateType.TRANSACTIONAL, opts);
-    }
-
-    /**
      * NonTransactional for redis.
      * */
     public static StateFactory nonTransactional(JedisPoolConfig jedisPoolConfig) {
@@ -199,34 +150,11 @@ public class RedisMapState<T> implements IBackingMap<T> {
         return new Factory(jedisPoolConfig, StateType.NON_TRANSACTIONAL, opts);
     }
 
-    /**
-     * NonTransactional for redis-cluster.
-     * */
-    public static StateFactory nonTransactional(JedisClusterConfig jedisClusterConfig) {
-        return nonTransactional(jedisClusterConfig, new Options());
-    }
-
-    public static StateFactory nonTransactional(JedisClusterConfig jedisClusterConfig, String hkey) {
-        Options opts = new Options();
-        opts.hkey = hkey;
-        return nonTransactional(jedisClusterConfig, opts);
-    }
-
-    public static StateFactory nonTransactional(JedisClusterConfig jedisClusterConfig, KeyFactory factory) {
-        Options opts = new Options();
-        opts.keyFactory = factory;
-        return nonTransactional(jedisClusterConfig, opts);
-    }
-
-    public static StateFactory nonTransactional(JedisClusterConfig jedisClusterConfig, Options<Object> opts) {
-        return new Factory(jedisClusterConfig, StateType.NON_TRANSACTIONAL, opts);
-    }
-
-
-
     protected static class Factory implements StateFactory {
+        // TODO : serialize redis.clients.jedis.JedisPoolConfig
+        public static final redis.clients.jedis.JedisPoolConfig DEFAULT_POOL_CONFIG = new redis.clients.jedis.JedisPoolConfig();
+
         JedisPoolConfig jedisPoolConfig;
-        JedisClusterConfig jedisClusterConfig;
 
         StateType type;
         Serializer serializer;
@@ -251,34 +179,14 @@ public class RedisMapState<T> implements IBackingMap<T> {
             }
         }
 
-        public Factory(JedisClusterConfig jedisClusterConfig, StateType type, Options options) {
-            this.jedisClusterConfig = jedisClusterConfig;
-            this.type = type;
-            this.options = options;
-
-            this.keyFactory = options.keyFactory;
-            if (this.keyFactory == null) {
-                this.keyFactory = new DefaultKeyFactory();
-            }
-            this.serializer = options.serializer;
-            if (this.serializer == null) {
-                this.serializer = DEFAULT_SERIALIZERS.get(type);
-                if (this.serializer == null) {
-                    throw new RuntimeException("Couldn't find serializer for state type: " + type);
-                }
-            }
-        }
-
         public State makeState(@SuppressWarnings("rawtypes") Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
-            JedisCommandsInstanceContainer container;
-            if (jedisPoolConfig != null) {
-                container = JedisCommandsContainerBuilder.build(jedisPoolConfig);
-            } else if (jedisClusterConfig != null) {
-                container = JedisCommandsContainerBuilder.build(jedisClusterConfig);
-            } else {
-                throw new IllegalArgumentException("Jedis configuration not found");
-            }
-            RedisMapState state = new RedisMapState(container, options, serializer, keyFactory);
+            JedisPool jedisPool = new JedisPool(DEFAULT_POOL_CONFIG,
+                                                    jedisPoolConfig.getHost(),
+                                                    jedisPoolConfig.getPort(),
+                                                    jedisPoolConfig.getTimeout(),
+                                                    jedisPoolConfig.getPassword(),
+                                                    jedisPoolConfig.getDatabase());
+            RedisMapState state = new RedisMapState(jedisPool, options, serializer, keyFactory);
             CachedMap c = new CachedMap(state, options.localCacheSize);
 
             MapState ms;
@@ -299,14 +207,14 @@ public class RedisMapState<T> implements IBackingMap<T> {
         }
     }
 
-    private transient JedisCommandsInstanceContainer container;
+    private JedisPool jedisPool;
     private Options options;
     private Serializer serializer;
     private KeyFactory keyFactory;
 
-    public RedisMapState(JedisCommandsInstanceContainer container, Options options,
+    public RedisMapState(JedisPool jedisPool, Options options,
                                             Serializer<T> serializer, KeyFactory keyFactory) {
-        this.container = container;
+        this.jedisPool = jedisPool;
         this.options = options;
         this.serializer = serializer;
         this.keyFactory = keyFactory;
@@ -318,37 +226,26 @@ public class RedisMapState<T> implements IBackingMap<T> {
         }
         if (Strings.isNullOrEmpty(this.options.hkey)) {
             String[] stringKeys = buildKeys(keys);
-            List<String> values = Lists.newArrayList();
-
-            JedisCommands jedisCommands = null;
+            Jedis jedis = null;
             try {
-                jedisCommands = container.getInstance();
-                if (jedisCommands instanceof Jedis) {
-                    //Todo because jedisCommands not support mget, we use Jedis for mget if it is Jedis
-                    values = ((Jedis)jedisCommands).mget(stringKeys);
-                } else {
-                    for (String stringKey : stringKeys) {
-                        String value = jedisCommands.get(stringKey);
-                        values.add(value);
-                    }
-                }
+                jedis = jedisPool.getResource();
+                List<String> values = jedis.mget(stringKeys);
+                return deserializeValues(keys, values);
             } finally {
-                if (jedisCommands != null) {
-                    container.returnInstance(jedisCommands);
+                if (jedis != null) {
+                    jedisPool.returnResource(jedis);
                 }
             }
-
-            return deserializeValues(keys, values);
         } else {
-            JedisCommands jedisCommands = null;
+            Jedis jedis = null;
             try {
-                jedisCommands = container.getInstance();
-                Map<String, String> keyValue = jedisCommands.hgetAll(this.options.hkey);
+                jedis = jedisPool.getResource();
+                Map<String, String> keyValue = jedis.hgetAll(this.options.hkey);
                 List<String> values = buildValuesFromMap(keys, keyValue);
                 return deserializeValues(keys, values);
             } finally {
-                if (jedisCommands != null) {
-                    container.returnInstance(jedisCommands);
+                if (jedis != null) {
+                    jedisPool.returnResource(jedis);
                 }
             }
         }
@@ -390,38 +287,31 @@ public class RedisMapState<T> implements IBackingMap<T> {
         }
 
         if (Strings.isNullOrEmpty(this.options.hkey)) {
-            JedisCommands jedisCommands = null;
+            Jedis jedis = null;
             try {
-                jedisCommands = container.getInstance();
-                if (jedisCommands instanceof Jedis) {
-                    //Todo because jedisCommands not support mget, we use Jedis for mget if it is Jedis
-                    String[] keyValue = buildKeyValuesList(keys, vals);
-                    ((Jedis)jedisCommands).mset(keyValue);
-                } else {
-                    for (int i = 0; i < keys.size(); i++) {
-                        String val = new String(serializer.serialize(vals.get(i)));
-                        String redisKey = keyFactory.build(keys.get(i));
-                        jedisCommands.set(redisKey, val);
-                    }
-                }
+                jedis = jedisPool.getResource();
+                String[] keyValue = buildKeyValuesList(keys, vals);
+                jedis.mset(keyValue);
             } finally {
-                if (jedisCommands != null) {
-                    container.returnInstance(jedisCommands);
+                if (jedis != null) {
+                    jedisPool.returnResource(jedis);
                 }
             }
         } else {
-            JedisCommands jedisCommands = null;
+            Jedis jedis = jedisPool.getResource();
             try {
-                jedisCommands = container.getInstance();
+                Pipeline pl = jedis.pipelined();
+                pl.multi();
+
                 for (int i = 0; i < keys.size(); i++) {
                     String val = new String(serializer.serialize(vals.get(i)));
-                    String redisKey = keyFactory.build(keys.get(i));
-                    jedisCommands.hset(this.options.hkey, redisKey, val);
+                    pl.hset(this.options.hkey, keyFactory.build(keys.get(i)), val);
                 }
+
+                pl.exec();
+                pl.sync();
             } finally {
-                if (jedisCommands != null) {
-                    container.returnInstance(jedisCommands);
-                }
+                jedisPool.returnResource(jedis);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/storm/blob/0f9438fc/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisState.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisState.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisState.java
index 47d2a28..cc5933f 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisState.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisState.java
@@ -18,13 +18,11 @@
 package org.apache.storm.redis.trident.state;
 
 import backtype.storm.task.IMetricsContext;
-import org.apache.storm.redis.util.config.JedisClusterConfig;
 import org.apache.storm.redis.util.config.JedisPoolConfig;
-import org.apache.storm.redis.util.container.JedisCommandsContainerBuilder;
-import org.apache.storm.redis.util.container.JedisCommandsInstanceContainer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import redis.clients.jedis.JedisCommands;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.JedisPool;
 import storm.trident.state.State;
 import storm.trident.state.StateFactory;
 
@@ -42,49 +40,45 @@ public class RedisState implements State {
     }
 
     public static class Factory implements StateFactory {
+        // TODO : serialize redis.clients.jedis.JedisPoolConfig
+        public static final redis.clients.jedis.JedisPoolConfig DEFAULT_POOL_CONFIG = new redis.clients.jedis.JedisPoolConfig();
+
         private JedisPoolConfig jedisPoolConfig;
-        private JedisClusterConfig jedisClusterConfig;
 
         public Factory(JedisPoolConfig config) {
             this.jedisPoolConfig = config;
         }
 
-        public Factory(JedisClusterConfig config) {
-            this.jedisClusterConfig = config;
-        }
-
         public State makeState(@SuppressWarnings("rawtypes") Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
-            JedisCommandsInstanceContainer container;
-            if (jedisPoolConfig != null) {
-                container = JedisCommandsContainerBuilder.build(jedisPoolConfig);
-            } else if (jedisClusterConfig != null) {
-                container = JedisCommandsContainerBuilder.build(jedisClusterConfig);
-            } else {
-                throw new IllegalArgumentException("Jedis configuration not found");
-            }
+            JedisPool jedisPool = new JedisPool(DEFAULT_POOL_CONFIG,
+                                                jedisPoolConfig.getHost(),
+                                                jedisPoolConfig.getPort(),
+                                                jedisPoolConfig.getTimeout(),
+                                                jedisPoolConfig.getPassword(),
+                                                jedisPoolConfig.getDatabase());
 
-            return new RedisState(container);
+            return new RedisState(jedisPool);
         }
     }
 
-    private transient JedisCommandsInstanceContainer container;
+    private JedisPool jedisPool;
 
-    public RedisState(JedisCommandsInstanceContainer container) {
-        this.container = container;
+    public RedisState(JedisPool jedisPool) {
+        this.jedisPool = jedisPool;
     }
 
     /**
-     * The state updater and querier can get a JedisCommands instance
+     * The state updater and querier can get a Jedis instance
      * */
-    public JedisCommands getInstance() {
-        return this.container.getInstance();
+    public Jedis getJedis() {
+        return this.jedisPool.getResource();
     }
 
     /**
-     * The state updater and querier return the JedisCommands instance
+     * The state updater and querier return the Jedis instance
      * */
-    public void returnInstance(JedisCommands instance) {
-        this.container.returnInstance(instance);
+    public void returnJedis(Jedis jedis) {
+        this.jedisPool.returnResource(jedis);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/storm/blob/0f9438fc/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateQuerier.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateQuerier.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateQuerier.java
index 1f6a090..051088e 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateQuerier.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateQuerier.java
@@ -22,16 +22,13 @@ import com.google.common.collect.Lists;
 import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import redis.clients.jedis.JedisCommands;
+import redis.clients.jedis.Jedis;
 import storm.trident.operation.TridentCollector;
 import storm.trident.state.BaseQueryFunction;
 import storm.trident.tuple.TridentTuple;
 
 import java.util.List;
 
-/**
- * Created by judasheng on 14-12-12.
- */
 public class RedisStateQuerier extends BaseQueryFunction<RedisState, String> {
     private static final Logger logger = LoggerFactory.getLogger(RedisState.class);
 
@@ -45,28 +42,24 @@ public class RedisStateQuerier extends BaseQueryFunction<RedisState, String> {
 
     @Override
     public List<String> batchRetrieve(RedisState redisState, List<TridentTuple> inputs) {
-        List<String> ret = Lists.newArrayList();
+        List<String> keys = Lists.newArrayList();
+        for (TridentTuple input : inputs) {
+            String key = this.tupleMapper.getKeyFromTridentTuple(input);
+            if (redisKeyPrefix != null && redisKeyPrefix.length() > 0) {
+                key = redisKeyPrefix + key;
+            }
+            keys.add(key);
+        }
 
-        JedisCommands jedisCommands = null;
+        Jedis jedis = null;
         try {
-            jedisCommands = redisState.getInstance();
-            for (TridentTuple input : inputs) {
-                String key = this.tupleMapper.getKeyFromTridentTuple(input);
-                if (redisKeyPrefix != null && redisKeyPrefix.length() > 0) {
-                    key = redisKeyPrefix + key;
-                }
-                String value = jedisCommands.get(key);
-                ret.add(value);
-
-                logger.debug("redis get key[" + key + "] count[" + value + "]");
-            }
+            jedis = redisState.getJedis();
+            return jedis.mget(keys.toArray(new String[keys.size()]));
         } finally {
-            if (jedisCommands != null) {
-                redisState.returnInstance(jedisCommands);
+            if (jedis != null) {
+                redisState.returnJedis(jedis);
             }
         }
-
-        return ret;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/storm/blob/0f9438fc/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetCountQuerier.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetCountQuerier.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetCountQuerier.java
index 42420bc..5b04d59 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetCountQuerier.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetCountQuerier.java
@@ -21,7 +21,7 @@ import backtype.storm.tuple.Values;
 import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import redis.clients.jedis.JedisCommands;
+import redis.clients.jedis.Jedis;
 import storm.trident.operation.TridentCollector;
 import storm.trident.state.BaseQueryFunction;
 import storm.trident.tuple.TridentTuple;
@@ -44,22 +44,22 @@ public class RedisStateSetCountQuerier extends BaseQueryFunction<RedisState, Lon
     public List<Long> batchRetrieve(RedisState redisState, List<TridentTuple> inputs) {
         List<Long> ret = new ArrayList<Long>();
 
-        JedisCommands jedisCommands = null;
+        Jedis jedis = null;
         try {
-            jedisCommands = redisState.getInstance();
+            jedis = redisState.getJedis();
             for (TridentTuple input : inputs) {
                 String key = this.tupleMapper.getKeyFromTridentTuple(input);
                 if (redisKeyPrefix != null && redisKeyPrefix.length() > 0) {
                     key = redisKeyPrefix + key;
                 }
-                long count = jedisCommands.scard(key);
+                long count = jedis.scard(key);
                 ret.add(count);
 
                 logger.debug("redis get key[" + key + "] count[" + count + "]");
             }
         } finally {
-            if (jedisCommands != null) {
-                redisState.returnInstance(jedisCommands);
+            if (jedis != null) {
+                redisState.returnJedis(jedis);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/storm/blob/0f9438fc/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java
index f24caf5..2134d99 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java
@@ -21,7 +21,7 @@ import backtype.storm.tuple.Values;
 import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import redis.clients.jedis.JedisCommands;
+import redis.clients.jedis.Jedis;
 import storm.trident.operation.TridentCollector;
 import storm.trident.state.BaseStateUpdater;
 import storm.trident.tuple.TridentTuple;
@@ -52,9 +52,9 @@ public class RedisStateSetUpdater extends BaseStateUpdater<RedisState> {
                             TridentCollector collector) {
         long expireAt = System.currentTimeMillis() + expireIntervalMs;
 
-        JedisCommands jedisCommands = null;
+        Jedis jedis = null;
         try {
-            jedisCommands = redisState.getInstance();
+            jedis = redisState.getJedis();
             for (TridentTuple input : inputs) {
                 String key = this.tupleMapper.getKeyFromTridentTuple(input);
                 String redisKey = key;
@@ -65,15 +65,15 @@ public class RedisStateSetUpdater extends BaseStateUpdater<RedisState> {
 
                 logger.debug("update key[" + key + "] redisKey[" + redisKey + "] value[" + value + "]");
 
-                jedisCommands.sadd(redisKey, value);
-                jedisCommands.expireAt(redisKey, expireAt);
-                Long count = jedisCommands.scard(redisKey);
+                jedis.sadd(redisKey, value);
+                jedis.expireAt(redisKey, expireAt);
+                Long count = jedis.scard(redisKey);
 
                 collector.emit(new Values(key, count));
             }
         } finally {
-            if (jedisCommands != null) {
-                redisState.returnInstance(jedisCommands);
+            if (jedis != null) {
+                redisState.returnJedis(jedis);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/storm/blob/0f9438fc/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java
index a832995..6fdede5 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java
@@ -20,7 +20,7 @@ package org.apache.storm.redis.trident.state;
 import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import redis.clients.jedis.JedisCommands;
+import redis.clients.jedis.Jedis;
 import storm.trident.operation.TridentCollector;
 import storm.trident.state.BaseStateUpdater;
 import storm.trident.tuple.TridentTuple;
@@ -51,9 +51,9 @@ public class RedisStateUpdater extends BaseStateUpdater<RedisState> {
                             TridentCollector collector) {
         long expireAt = System.currentTimeMillis() + expireIntervalMs;
 
-        JedisCommands jedisCommands = null;
+        Jedis jedis = null;
         try {
-            jedisCommands = redisState.getInstance();
+            jedis = redisState.getJedis();
             for (TridentTuple input : inputs) {
                 String key = this.tupleMapper.getKeyFromTridentTuple(input);
                 String redisKey = key;
@@ -64,12 +64,12 @@ public class RedisStateUpdater extends BaseStateUpdater<RedisState> {
 
                 logger.debug("update key[" + key + "] redisKey[" + redisKey + "] value[" + value + "]");
 
-                jedisCommands.set(redisKey, value);
-                jedisCommands.expireAt(redisKey, expireAt);
+                jedis.set(redisKey, value);
+                jedis.expireAt(redisKey, expireAt);
             }
         } finally {
-            if (jedisCommands != null) {
-                redisState.returnInstance(jedisCommands);
+            if (jedis != null) {
+                redisState.returnJedis(jedis);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/storm/blob/0f9438fc/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedisCluster.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedisCluster.java b/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedisCluster.java
index c4d55dc..31434dc 100644
--- a/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedisCluster.java
+++ b/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedisCluster.java
@@ -24,11 +24,10 @@ import backtype.storm.generated.StormTopology;
 import backtype.storm.tuple.Fields;
 import backtype.storm.tuple.Values;
 import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
-import org.apache.storm.redis.trident.state.RedisState;
-import org.apache.storm.redis.trident.state.RedisStateQuerier;
-import org.apache.storm.redis.trident.state.RedisStateUpdater;
+import org.apache.storm.redis.trident.state.RedisClusterState;
+import org.apache.storm.redis.trident.state.RedisClusterStateQuerier;
+import org.apache.storm.redis.trident.state.RedisClusterStateUpdater;
 import org.apache.storm.redis.util.config.JedisClusterConfig;
-import redis.clients.jedis.HostAndPort;
 import storm.trident.Stream;
 import storm.trident.TridentState;
 import storm.trident.TridentTopology;
@@ -57,19 +56,19 @@ public class WordCountTridentRedisCluster {
         JedisClusterConfig clusterConfig = new JedisClusterConfig.Builder().setNodes(nodes)
                                         .build();
         TridentTupleMapper tupleMapper = new WordCountTupleMapper();
-        RedisState.Factory factory = new RedisState.Factory(clusterConfig);
+        RedisClusterState.Factory factory = new RedisClusterState.Factory(clusterConfig);
 
         TridentTopology topology = new TridentTopology();
         Stream stream = topology.newStream("spout1", spout);
 
         stream.partitionPersist(factory,
                                 fields,
-                                new RedisStateUpdater("test_", tupleMapper, 86400000),
+                                new RedisClusterStateUpdater("test_", tupleMapper, 86400000),
                                 new Fields());
 
         TridentState state = topology.newStaticState(factory);
         stream = stream.stateQuery(state, new Fields("word"),
-                                new RedisStateQuerier("test_", tupleMapper),
+                                new RedisClusterStateQuerier("test_", tupleMapper),
                                 new Fields("columnName","columnValue"));
         stream.each(new Fields("word","columnValue"), new PrintFunction(), new Fields());
         return topology.build();

http://git-wip-us.apache.org/repos/asf/storm/blob/0f9438fc/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedisClusterMap.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedisClusterMap.java b/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedisClusterMap.java
new file mode 100644
index 0000000..e9ae54d
--- /dev/null
+++ b/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedisClusterMap.java
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident;
+
+import backtype.storm.Config;
+import backtype.storm.LocalCluster;
+import backtype.storm.StormSubmitter;
+import backtype.storm.generated.StormTopology;
+import backtype.storm.tuple.Fields;
+import backtype.storm.tuple.Values;
+import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
+import org.apache.storm.redis.trident.state.RedisClusterMapState;
+import org.apache.storm.redis.trident.state.RedisClusterStateUpdater;
+import org.apache.storm.redis.trident.state.RedisStateQuerier;
+import org.apache.storm.redis.util.config.JedisClusterConfig;
+import storm.trident.Stream;
+import storm.trident.TridentState;
+import storm.trident.TridentTopology;
+import storm.trident.operation.builtin.MapGet;
+import storm.trident.operation.builtin.Sum;
+import storm.trident.state.StateFactory;
+import storm.trident.testing.FixedBatchSpout;
+
+import java.net.InetSocketAddress;
+import java.util.HashSet;
+import java.util.Set;
+
+public class WordCountTridentRedisClusterMap {
+    public static StormTopology buildTopology(String redisHostPort){
+        Fields fields = new Fields("word", "count");
+        FixedBatchSpout spout = new FixedBatchSpout(fields, 4,
+                new Values("storm", 1),
+                new Values("trident", 1),
+                new Values("needs", 1),
+                new Values("javadoc", 1)
+        );
+        spout.setCycle(true);
+
+        Set<InetSocketAddress> nodes = new HashSet<InetSocketAddress>();
+        for (String hostPort : redisHostPort.split(",")) {
+            String[] host_port = hostPort.split(":");
+            nodes.add(new InetSocketAddress(host_port[0], Integer.valueOf(host_port[1])));
+        }
+        JedisClusterConfig clusterConfig = new JedisClusterConfig.Builder().setNodes(nodes)
+                                        .build();
+        TridentTupleMapper tupleMapper = new WordCountTupleMapper();
+        StateFactory factory = RedisClusterMapState.transactional(clusterConfig);
+
+        TridentTopology topology = new TridentTopology();
+        Stream stream = topology.newStream("spout1", spout);
+
+        TridentState state = stream.groupBy(new Fields("word"))
+                .persistentAggregate(factory, new Fields("count"), new Sum(), new Fields("sum"));
+
+        stream.stateQuery(state, new Fields("word"), new MapGet(), new Fields("sum"))
+                .each(new Fields("word", "sum"), new PrintFunction(), new Fields());
+        return topology.build();
+    }
+
+    public static void main(String[] args) throws Exception {
+        if (args.length != 2) {
+            System.out.println("Usage: WordCountTrident 0(storm-local)|1(storm-cluster) 127.0.0.1:6379,127.0.0.1:6380");
+            System.exit(1);
+        }
+
+        Integer flag = Integer.valueOf(args[0]);
+        String redisHostPort = args[1];
+
+        Config conf = new Config();
+        conf.setMaxSpoutPending(5);
+        if (flag == 0) {
+            LocalCluster cluster = new LocalCluster();
+            cluster.submitTopology("test_wordCounter_for_redis", conf, buildTopology(redisHostPort));
+            Thread.sleep(60 * 1000);
+            cluster.killTopology("test_wordCounter_for_redis");
+            cluster.shutdown();
+            System.exit(0);
+        } else if(flag == 1) {
+            conf.setNumWorkers(3);
+            StormSubmitter.submitTopology("test_wordCounter_for_redis", conf, buildTopology(redisHostPort));
+        } else {
+            System.out.println("Usage: WordCountTrident 0(storm-local)|1(storm-cluster) redis-host redis-port");
+        }
+    }
+
+}


[09/23] storm git commit: add test case to storm-redis

Posted by bo...@apache.org.
add test case to storm-redis


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

Branch: refs/heads/master
Commit: ff36ac874b03fefefe7d25298238d5c2cc4493d5
Parents: b2c0731
Author: dashengju <da...@qq.com>
Authored: Wed Dec 31 17:11:22 2014 +0800
Committer: dashengju <da...@qq.com>
Committed: Wed Dec 31 17:11:22 2014 +0800

----------------------------------------------------------------------
 external/storm-redis/pom.xml                    |  48 +++++++++
 .../redis/trident/state/RedisMapState.java      |  28 +++--
 .../redis/trident/state/RedisStateQuerier.java  |   7 +-
 .../state/RedisStateSetCountQuerier.java        |   7 +-
 .../trident/state/RedisStateSetUpdater.java     |   7 +-
 .../redis/trident/state/RedisStateUpdater.java  |   7 +-
 .../redis/util/config/JedisClusterConfig.java   |  18 ++--
 .../redis/util/container/JedisContainer.java    |   4 +
 .../storm/redis/topology/LookupWordCount.java   |  12 +--
 .../redis/topology/PersistentWordCount.java     |   2 +-
 .../storm/redis/trident/PrintFunction.java      |  40 +++++++
 .../redis/trident/WordCountTridentRedis.java    |  97 +++++++++++++++++
 .../trident/WordCountTridentRedisCluster.java   | 104 +++++++++++++++++++
 .../redis/trident/WordCountTridentRedisMap.java |  95 +++++++++++++++++
 .../redis/trident/WordCountTupleMapper.java     |  16 +++
 15 files changed, 461 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/ff36ac87/external/storm-redis/pom.xml
----------------------------------------------------------------------
diff --git a/external/storm-redis/pom.xml b/external/storm-redis/pom.xml
index 46c20a5..6213ae1 100644
--- a/external/storm-redis/pom.xml
+++ b/external/storm-redis/pom.xml
@@ -56,5 +56,53 @@
             <artifactId>jedis</artifactId>
             <version>${jedis.version}</version>
         </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>18.0</version>
+        </dependency>
     </dependencies>
+
+    <!--
+    <build>
+        <sourceDirectory>src</sourceDirectory>
+        <resources>
+            <resource>
+                <directory>${basedir}/multilang</directory>
+            </resource>
+            <resource>
+                <directory>${basedir}/resources</directory>
+            </resource>
+        </resources>
+
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>
+                <version>2.2</version>
+                <configuration>
+                    <artifactSet>
+                        <excludes>
+                            <exclude>junit:junit</exclude>
+                            <exclude>org.slf4j:slf4j-simple</exclude>
+                            <exclude>org.slf4j:slf4j-log4j12</exclude>
+                            <exclude>org.apache.zookeeper</exclude>
+                        </excludes>
+                    </artifactSet>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>shade</goal>
+                        </goals>
+                        <configuration>
+                            <finalName>${project.artifactId}-${project.version}-with-dependencies</finalName>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+    -->
 </project>

http://git-wip-us.apache.org/repos/asf/storm/blob/ff36ac87/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
index 647167e..7aa9dc9 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
@@ -320,8 +320,9 @@ public class RedisMapState<T> implements IBackingMap<T> {
             String[] stringKeys = buildKeys(keys);
             List<String> values = Lists.newArrayList();
 
-            JedisCommands jedisCommands = container.getInstance();
+            JedisCommands jedisCommands = null;
             try {
+                jedisCommands = container.getInstance();
                 if (jedisCommands instanceof Jedis) {
                     //Todo because jedisCommands not support mget, we use Jedis for mget if it is Jedis
                     values = ((Jedis)jedisCommands).mget(stringKeys);
@@ -332,18 +333,23 @@ public class RedisMapState<T> implements IBackingMap<T> {
                     }
                 }
             } finally {
-                container.returnInstance(jedisCommands);
+                if (jedisCommands != null) {
+                    container.returnInstance(jedisCommands);
+                }
             }
 
             return deserializeValues(keys, values);
         } else {
-            JedisCommands jedisCommands = container.getInstance();
+            JedisCommands jedisCommands = null;
             try {
+                jedisCommands = container.getInstance();
                 Map<String, String> keyValue = jedisCommands.hgetAll(this.options.hkey);
                 List<String> values = buildValuesFromMap(keys, keyValue);
                 return deserializeValues(keys, values);
             } finally {
-                container.returnInstance(jedisCommands);
+                if (jedisCommands != null) {
+                    container.returnInstance(jedisCommands);
+                }
             }
         }
     }
@@ -384,8 +390,9 @@ public class RedisMapState<T> implements IBackingMap<T> {
         }
 
         if (Strings.isNullOrEmpty(this.options.hkey)) {
-            JedisCommands jedisCommands = container.getInstance();
+            JedisCommands jedisCommands = null;
             try {
+                jedisCommands = container.getInstance();
                 if (jedisCommands instanceof Jedis) {
                     //Todo because jedisCommands not support mget, we use Jedis for mget if it is Jedis
                     String[] keyValue = buildKeyValuesList(keys, vals);
@@ -398,18 +405,23 @@ public class RedisMapState<T> implements IBackingMap<T> {
                     }
                 }
             } finally {
-                container.returnInstance(jedisCommands);
+                if (jedisCommands != null) {
+                    container.returnInstance(jedisCommands);
+                }
             }
         } else {
-            JedisCommands jedisCommands = container.getInstance();
+            JedisCommands jedisCommands = null;
             try {
+                jedisCommands = container.getInstance();
                 for (int i = 0; i < keys.size(); i++) {
                     String val = new String(serializer.serialize(vals.get(i)));
                     String redisKey = keyFactory.build(keys.get(i));
                     jedisCommands.hset(this.options.hkey, redisKey, val);
                 }
             } finally {
-                container.returnInstance(jedisCommands);
+                if (jedisCommands != null) {
+                    container.returnInstance(jedisCommands);
+                }
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/storm/blob/ff36ac87/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateQuerier.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateQuerier.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateQuerier.java
index e01f8b8..1f6a090 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateQuerier.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateQuerier.java
@@ -47,8 +47,9 @@ public class RedisStateQuerier extends BaseQueryFunction<RedisState, String> {
     public List<String> batchRetrieve(RedisState redisState, List<TridentTuple> inputs) {
         List<String> ret = Lists.newArrayList();
 
-        JedisCommands jedisCommands = redisState.getInstance();
+        JedisCommands jedisCommands = null;
         try {
+            jedisCommands = redisState.getInstance();
             for (TridentTuple input : inputs) {
                 String key = this.tupleMapper.getKeyFromTridentTuple(input);
                 if (redisKeyPrefix != null && redisKeyPrefix.length() > 0) {
@@ -60,7 +61,9 @@ public class RedisStateQuerier extends BaseQueryFunction<RedisState, String> {
                 logger.debug("redis get key[" + key + "] count[" + value + "]");
             }
         } finally {
-            redisState.returnInstance(jedisCommands);
+            if (jedisCommands != null) {
+                redisState.returnInstance(jedisCommands);
+            }
         }
 
         return ret;

http://git-wip-us.apache.org/repos/asf/storm/blob/ff36ac87/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetCountQuerier.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetCountQuerier.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetCountQuerier.java
index 506f1b1..42420bc 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetCountQuerier.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetCountQuerier.java
@@ -44,8 +44,9 @@ public class RedisStateSetCountQuerier extends BaseQueryFunction<RedisState, Lon
     public List<Long> batchRetrieve(RedisState redisState, List<TridentTuple> inputs) {
         List<Long> ret = new ArrayList<Long>();
 
-        JedisCommands jedisCommands = redisState.getInstance();
+        JedisCommands jedisCommands = null;
         try {
+            jedisCommands = redisState.getInstance();
             for (TridentTuple input : inputs) {
                 String key = this.tupleMapper.getKeyFromTridentTuple(input);
                 if (redisKeyPrefix != null && redisKeyPrefix.length() > 0) {
@@ -57,7 +58,9 @@ public class RedisStateSetCountQuerier extends BaseQueryFunction<RedisState, Lon
                 logger.debug("redis get key[" + key + "] count[" + count + "]");
             }
         } finally {
-            redisState.returnInstance(jedisCommands);
+            if (jedisCommands != null) {
+                redisState.returnInstance(jedisCommands);
+            }
         }
 
         return ret;

http://git-wip-us.apache.org/repos/asf/storm/blob/ff36ac87/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java
index 742c9ac..f24caf5 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java
@@ -52,8 +52,9 @@ public class RedisStateSetUpdater extends BaseStateUpdater<RedisState> {
                             TridentCollector collector) {
         long expireAt = System.currentTimeMillis() + expireIntervalMs;
 
-        JedisCommands jedisCommands = redisState.getInstance();
+        JedisCommands jedisCommands = null;
         try {
+            jedisCommands = redisState.getInstance();
             for (TridentTuple input : inputs) {
                 String key = this.tupleMapper.getKeyFromTridentTuple(input);
                 String redisKey = key;
@@ -71,7 +72,9 @@ public class RedisStateSetUpdater extends BaseStateUpdater<RedisState> {
                 collector.emit(new Values(key, count));
             }
         } finally {
-            redisState.returnInstance(jedisCommands);
+            if (jedisCommands != null) {
+                redisState.returnInstance(jedisCommands);
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/storm/blob/ff36ac87/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java
index 3a4d42b..a832995 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java
@@ -51,8 +51,9 @@ public class RedisStateUpdater extends BaseStateUpdater<RedisState> {
                             TridentCollector collector) {
         long expireAt = System.currentTimeMillis() + expireIntervalMs;
 
-        JedisCommands jedisCommands = redisState.getInstance();
+        JedisCommands jedisCommands = null;
         try {
+            jedisCommands = redisState.getInstance();
             for (TridentTuple input : inputs) {
                 String key = this.tupleMapper.getKeyFromTridentTuple(input);
                 String redisKey = key;
@@ -67,7 +68,9 @@ public class RedisStateUpdater extends BaseStateUpdater<RedisState> {
                 jedisCommands.expireAt(redisKey, expireAt);
             }
         } finally {
-            redisState.returnInstance(jedisCommands);
+            if (jedisCommands != null) {
+                redisState.returnInstance(jedisCommands);
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/storm/blob/ff36ac87/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisClusterConfig.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisClusterConfig.java b/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisClusterConfig.java
index 7d421b2..355119a 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisClusterConfig.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisClusterConfig.java
@@ -22,21 +22,27 @@ import redis.clients.jedis.HostAndPort;
 import redis.clients.jedis.Protocol;
 
 import java.io.Serializable;
+import java.net.InetSocketAddress;
+import java.util.HashSet;
 import java.util.Set;
 
 public class JedisClusterConfig implements Serializable {
-    private Set<HostAndPort> nodes;
+    private Set<InetSocketAddress> nodes;
     private int timeout;
     private int maxRedirections;
 
-    public JedisClusterConfig(Set<HostAndPort> nodes, int timeout, int maxRedirections) {
+    public JedisClusterConfig(Set<InetSocketAddress> nodes, int timeout, int maxRedirections) {
         this.nodes = nodes;
         this.timeout = timeout;
         this.maxRedirections = maxRedirections;
     }
 
     public Set<HostAndPort> getNodes() {
-        return nodes;
+        Set<HostAndPort> ret = new HashSet<HostAndPort>();
+        for (InetSocketAddress node : nodes) {
+            ret.add(new HostAndPort(node.getHostName(), node.getPort()));
+        }
+        return ret;
     }
 
     public int getTimeout() {
@@ -47,12 +53,12 @@ public class JedisClusterConfig implements Serializable {
         return maxRedirections;
     }
 
-    static class Builder {
-        private Set<HostAndPort> nodes;
+    public static class Builder {
+        private Set<InetSocketAddress> nodes;
         private int timeout = Protocol.DEFAULT_TIMEOUT;
         private int maxRedirections = 5;
 
-        public Builder setNodes(Set<HostAndPort> nodes) {
+        public Builder setNodes(Set<InetSocketAddress> nodes) {
             this.nodes = nodes;
             return this;
         }

http://git-wip-us.apache.org/repos/asf/storm/blob/ff36ac87/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisContainer.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisContainer.java b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisContainer.java
index de9f1aa..e75cccc 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisContainer.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisContainer.java
@@ -42,6 +42,10 @@ public class JedisContainer implements JedisCommandsInstanceContainer, Closeable
 
     @Override
     public void returnInstance(JedisCommands jedisCommands) {
+        if (jedisCommands == null) {
+            return;
+        }
+
         try {
             ((Closeable) jedisCommands).close();
         } catch (IOException e) {

http://git-wip-us.apache.org/repos/asf/storm/blob/ff36ac87/external/storm-redis/src/test/java/org/apache/storm/redis/topology/LookupWordCount.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/test/java/org/apache/storm/redis/topology/LookupWordCount.java b/external/storm-redis/src/test/java/org/apache/storm/redis/topology/LookupWordCount.java
index 42d3800..a62fdff 100644
--- a/external/storm-redis/src/test/java/org/apache/storm/redis/topology/LookupWordCount.java
+++ b/external/storm-redis/src/test/java/org/apache/storm/redis/topology/LookupWordCount.java
@@ -74,14 +74,10 @@ public class LookupWordCount {
                     // skip
                     LOG.warn("Word not found in Redis - word : " + wordName);
                 }
-            } catch (NumberFormatException e) {
-                LOG.error("Counter Type seems not stored to integer", e);
-            } catch (JedisConnectionException e) {
-                throw new RuntimeException("Unfortunately, this test requires redis-server running", e);
-            } catch (JedisException e) {
-                LOG.error("Exception occurred from Jedis/Redis", e);
             } finally {
-                returnInstance(jedisCommands);
+                if (jedisCommands != null) {
+                    returnInstance(jedisCommands);
+                }
                 this.collector.ack(input);
             }
         }
@@ -99,7 +95,7 @@ public class LookupWordCount {
         String host = TEST_REDIS_HOST;
         int port = TEST_REDIS_PORT;
 
-        if (args.length > 2) {
+        if (args.length >= 2) {
             host = args[0];
             port = Integer.parseInt(args[1]);
         }

http://git-wip-us.apache.org/repos/asf/storm/blob/ff36ac87/external/storm-redis/src/test/java/org/apache/storm/redis/topology/PersistentWordCount.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/test/java/org/apache/storm/redis/topology/PersistentWordCount.java b/external/storm-redis/src/test/java/org/apache/storm/redis/topology/PersistentWordCount.java
index a96696b..535d7b9 100644
--- a/external/storm-redis/src/test/java/org/apache/storm/redis/topology/PersistentWordCount.java
+++ b/external/storm-redis/src/test/java/org/apache/storm/redis/topology/PersistentWordCount.java
@@ -82,7 +82,7 @@ public class PersistentWordCount {
         String host = TEST_REDIS_HOST;
         int port = TEST_REDIS_PORT;
 
-        if (args.length > 2) {
+        if (args.length >= 2) {
             host = args[0];
             port = Integer.parseInt(args[1]);
         }

http://git-wip-us.apache.org/repos/asf/storm/blob/ff36ac87/external/storm-redis/src/test/java/org/apache/storm/redis/trident/PrintFunction.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/test/java/org/apache/storm/redis/trident/PrintFunction.java b/external/storm-redis/src/test/java/org/apache/storm/redis/trident/PrintFunction.java
new file mode 100644
index 0000000..6f465c9
--- /dev/null
+++ b/external/storm-redis/src/test/java/org/apache/storm/redis/trident/PrintFunction.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import storm.trident.operation.BaseFunction;
+import storm.trident.operation.TridentCollector;
+import storm.trident.tuple.TridentTuple;
+
+import java.util.Random;
+
+public class PrintFunction extends BaseFunction {
+
+    private static final Logger LOG = LoggerFactory.getLogger(PrintFunction.class);
+
+    private static final Random RANDOM = new Random();
+
+    @Override
+    public void execute(TridentTuple tuple, TridentCollector tridentCollector) {
+        if(RANDOM.nextInt(1000) > 995) {
+            LOG.info(tuple.toString());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/ff36ac87/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedis.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedis.java b/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedis.java
new file mode 100644
index 0000000..9a28cb7
--- /dev/null
+++ b/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedis.java
@@ -0,0 +1,97 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident;
+
+import backtype.storm.Config;
+import backtype.storm.LocalCluster;
+import backtype.storm.StormSubmitter;
+import backtype.storm.generated.StormTopology;
+import backtype.storm.tuple.Fields;
+import backtype.storm.tuple.Values;
+import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
+import org.apache.storm.redis.trident.state.RedisState;
+import org.apache.storm.redis.trident.state.RedisStateQuerier;
+import org.apache.storm.redis.trident.state.RedisStateUpdater;
+import org.apache.storm.redis.util.config.JedisPoolConfig;
+import storm.trident.Stream;
+import storm.trident.TridentState;
+import storm.trident.TridentTopology;
+import storm.trident.state.StateFactory;
+import storm.trident.testing.FixedBatchSpout;
+
+public class WordCountTridentRedis {
+    public static StormTopology buildTopology(String redisHost, Integer redisPort){
+        Fields fields = new Fields("word", "count");
+        FixedBatchSpout spout = new FixedBatchSpout(fields, 4,
+                new Values("storm", 1),
+                new Values("trident", 1),
+                new Values("needs", 1),
+                new Values("javadoc", 1)
+        );
+        spout.setCycle(true);
+
+        JedisPoolConfig poolConfig = new JedisPoolConfig.Builder()
+                                        .setHost(redisHost).setPort(redisPort)
+                                        .build();
+        TridentTupleMapper tupleMapper = new WordCountTupleMapper();
+        RedisState.Factory factory = new RedisState.Factory(poolConfig);
+
+        TridentTopology topology = new TridentTopology();
+        Stream stream = topology.newStream("spout1", spout);
+
+        stream.partitionPersist(factory,
+                                fields,
+                                new RedisStateUpdater("test_", tupleMapper, 86400000),
+                                new Fields());
+
+        TridentState state = topology.newStaticState(factory);
+        stream = stream.stateQuery(state, new Fields("word"),
+                                new RedisStateQuerier("test_", tupleMapper),
+                                new Fields("columnName","columnValue"));
+        stream.each(new Fields("word","columnValue"), new PrintFunction(), new Fields());
+        return topology.build();
+    }
+
+    public static void main(String[] args) throws Exception {
+        if (args.length != 3) {
+            System.out.println("Usage: WordCountTrident 0(storm-local)|1(storm-cluster) redis-host redis-port");
+            System.exit(1);
+        }
+
+        Integer flag = Integer.valueOf(args[0]);
+        String redisHost = args[1];
+        Integer redisPort = Integer.valueOf(args[2]);
+
+        Config conf = new Config();
+        conf.setMaxSpoutPending(5);
+        if (flag == 0) {
+            LocalCluster cluster = new LocalCluster();
+            cluster.submitTopology("test_wordCounter_for_redis", conf, buildTopology(redisHost, redisPort));
+            Thread.sleep(60 * 1000);
+            cluster.killTopology("test_wordCounter_for_redis");
+            cluster.shutdown();
+            System.exit(0);
+        } else if(flag == 1) {
+            conf.setNumWorkers(3);
+            StormSubmitter.submitTopology("test_wordCounter_for_redis", conf, buildTopology(redisHost, redisPort));
+        } else {
+            System.out.println("Usage: WordCountTrident 0(storm-local)|1(storm-cluster) redis-host redis-port");
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/ff36ac87/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedisCluster.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedisCluster.java b/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedisCluster.java
new file mode 100644
index 0000000..c4d55dc
--- /dev/null
+++ b/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedisCluster.java
@@ -0,0 +1,104 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident;
+
+import backtype.storm.Config;
+import backtype.storm.LocalCluster;
+import backtype.storm.StormSubmitter;
+import backtype.storm.generated.StormTopology;
+import backtype.storm.tuple.Fields;
+import backtype.storm.tuple.Values;
+import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
+import org.apache.storm.redis.trident.state.RedisState;
+import org.apache.storm.redis.trident.state.RedisStateQuerier;
+import org.apache.storm.redis.trident.state.RedisStateUpdater;
+import org.apache.storm.redis.util.config.JedisClusterConfig;
+import redis.clients.jedis.HostAndPort;
+import storm.trident.Stream;
+import storm.trident.TridentState;
+import storm.trident.TridentTopology;
+import storm.trident.testing.FixedBatchSpout;
+
+import java.net.InetSocketAddress;
+import java.util.HashSet;
+import java.util.Set;
+
+public class WordCountTridentRedisCluster {
+    public static StormTopology buildTopology(String redisHostPort){
+        Fields fields = new Fields("word", "count");
+        FixedBatchSpout spout = new FixedBatchSpout(fields, 4,
+                new Values("storm", 1),
+                new Values("trident", 1),
+                new Values("needs", 1),
+                new Values("javadoc", 1)
+        );
+        spout.setCycle(true);
+
+        Set<InetSocketAddress> nodes = new HashSet<InetSocketAddress>();
+        for (String hostPort : redisHostPort.split(",")) {
+            String[] host_port = hostPort.split(":");
+            nodes.add(new InetSocketAddress(host_port[0], Integer.valueOf(host_port[1])));
+        }
+        JedisClusterConfig clusterConfig = new JedisClusterConfig.Builder().setNodes(nodes)
+                                        .build();
+        TridentTupleMapper tupleMapper = new WordCountTupleMapper();
+        RedisState.Factory factory = new RedisState.Factory(clusterConfig);
+
+        TridentTopology topology = new TridentTopology();
+        Stream stream = topology.newStream("spout1", spout);
+
+        stream.partitionPersist(factory,
+                                fields,
+                                new RedisStateUpdater("test_", tupleMapper, 86400000),
+                                new Fields());
+
+        TridentState state = topology.newStaticState(factory);
+        stream = stream.stateQuery(state, new Fields("word"),
+                                new RedisStateQuerier("test_", tupleMapper),
+                                new Fields("columnName","columnValue"));
+        stream.each(new Fields("word","columnValue"), new PrintFunction(), new Fields());
+        return topology.build();
+    }
+
+    public static void main(String[] args) throws Exception {
+        if (args.length != 2) {
+            System.out.println("Usage: WordCountTrident 0(storm-local)|1(storm-cluster) 127.0.0.1:6379,127.0.0.1:6380");
+            System.exit(1);
+        }
+
+        Integer flag = Integer.valueOf(args[0]);
+        String redisHostPort = args[1];
+
+        Config conf = new Config();
+        conf.setMaxSpoutPending(5);
+        if (flag == 0) {
+            LocalCluster cluster = new LocalCluster();
+            cluster.submitTopology("test_wordCounter_for_redis", conf, buildTopology(redisHostPort));
+            Thread.sleep(60 * 1000);
+            cluster.killTopology("test_wordCounter_for_redis");
+            cluster.shutdown();
+            System.exit(0);
+        } else if(flag == 1) {
+            conf.setNumWorkers(3);
+            StormSubmitter.submitTopology("test_wordCounter_for_redis", conf, buildTopology(redisHostPort));
+        } else {
+            System.out.println("Usage: WordCountTrident 0(storm-local)|1(storm-cluster) redis-host redis-port");
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/ff36ac87/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedisMap.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedisMap.java b/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedisMap.java
new file mode 100644
index 0000000..b096e55
--- /dev/null
+++ b/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTridentRedisMap.java
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident;
+
+import backtype.storm.Config;
+import backtype.storm.LocalCluster;
+import backtype.storm.StormSubmitter;
+import backtype.storm.generated.StormTopology;
+import backtype.storm.tuple.Fields;
+import backtype.storm.tuple.Values;
+import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
+import org.apache.storm.redis.trident.state.RedisMapState;
+import org.apache.storm.redis.trident.state.RedisState;
+import org.apache.storm.redis.trident.state.RedisStateQuerier;
+import org.apache.storm.redis.trident.state.RedisStateUpdater;
+import org.apache.storm.redis.util.config.JedisPoolConfig;
+import storm.trident.Stream;
+import storm.trident.TridentState;
+import storm.trident.TridentTopology;
+import storm.trident.operation.builtin.MapGet;
+import storm.trident.operation.builtin.Sum;
+import storm.trident.state.StateFactory;
+import storm.trident.testing.FixedBatchSpout;
+
+public class WordCountTridentRedisMap {
+    public static StormTopology buildTopology(String redisHost, Integer redisPort){
+        Fields fields = new Fields("word", "count");
+        FixedBatchSpout spout = new FixedBatchSpout(fields, 4,
+                new Values("storm", 1),
+                new Values("trident", 1),
+                new Values("needs", 1),
+                new Values("javadoc", 1)
+        );
+        spout.setCycle(true);
+
+        JedisPoolConfig poolConfig = new JedisPoolConfig.Builder()
+                                        .setHost(redisHost).setPort(redisPort)
+                                        .build();
+        TridentTupleMapper tupleMapper = new WordCountTupleMapper();
+        StateFactory factory = RedisMapState.transactional(poolConfig);
+
+        TridentTopology topology = new TridentTopology();
+        Stream stream = topology.newStream("spout1", spout);
+
+        TridentState state = stream.groupBy(new Fields("word"))
+                .persistentAggregate(factory, new Fields("count"), new Sum(), new Fields("sum"));
+
+        stream.stateQuery(state, new Fields("word"), new MapGet(), new Fields("sum"))
+                .each(new Fields("word", "sum"), new PrintFunction(), new Fields());
+        return topology.build();
+    }
+
+    public static void main(String[] args) throws Exception {
+        if (args.length != 3) {
+            System.out.println("Usage: WordCountTrident 0(storm-local)|1(storm-cluster) redis-host redis-port");
+            System.exit(1);
+        }
+
+        Integer flag = Integer.valueOf(args[0]);
+        String redisHost = args[1];
+        Integer redisPort = Integer.valueOf(args[2]);
+
+        Config conf = new Config();
+        conf.setMaxSpoutPending(5);
+        if (flag == 0) {
+            LocalCluster cluster = new LocalCluster();
+            cluster.submitTopology("test_wordCounter_for_redis", conf, buildTopology(redisHost, redisPort));
+            Thread.sleep(60 * 1000);
+            cluster.killTopology("test_wordCounter_for_redis");
+            cluster.shutdown();
+            System.exit(0);
+        } else if(flag == 1) {
+            conf.setNumWorkers(3);
+            StormSubmitter.submitTopology("test_wordCounter_for_redis", conf, buildTopology(redisHost, redisPort));
+        } else {
+            System.out.println("Usage: WordCountTrident 0(storm-local)|1(storm-cluster) redis-host redis-port");
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/ff36ac87/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTupleMapper.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTupleMapper.java b/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTupleMapper.java
new file mode 100644
index 0000000..6454c9e
--- /dev/null
+++ b/external/storm-redis/src/test/java/org/apache/storm/redis/trident/WordCountTupleMapper.java
@@ -0,0 +1,16 @@
+package org.apache.storm.redis.trident;
+
+import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
+import storm.trident.tuple.TridentTuple;
+
+public class WordCountTupleMapper implements TridentTupleMapper {
+    @Override
+    public String getKeyFromTridentTuple(TridentTuple tuple) {
+        return tuple.getString(0);
+    }
+
+    @Override
+    public String getValueFromTridentTuple(TridentTuple tuple) {
+        return tuple.getInteger(1).toString();
+    }
+}


[20/23] storm git commit: Change Committer Sponsors

Posted by bo...@apache.org.
Change Committer Sponsors


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

Branch: refs/heads/master
Commit: 5daeb08226b646d06598e69fda36fcd9bdea21a1
Parents: dad3b80
Author: dashengju <da...@qq.com>
Authored: Wed Jan 21 10:56:09 2015 +0800
Committer: dashengju <da...@qq.com>
Committed: Wed Jan 21 10:56:09 2015 +0800

----------------------------------------------------------------------
 external/storm-redis/README.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/5daeb082/external/storm-redis/README.md
----------------------------------------------------------------------
diff --git a/external/storm-redis/README.md b/external/storm-redis/README.md
index 3dc030d..8e6fbce 100644
--- a/external/storm-redis/README.md
+++ b/external/storm-redis/README.md
@@ -134,7 +134,7 @@ under the License.
 
 ## Committer Sponsors
 
- * Bobby Evans ([bobby@apache.org](mailto:bobby@apache.org))
- * DashengJu ([dashengju@gmail.com](mailto:dashengju@gmail.com))
- * HeartSaVioR ([kabhwan@gmail.com](mailto:kabhwan@gmail.com))
+ * Robert Evans ([@revans2](https://github.com/revans2))
+ * DashengJu ([@dashengju](https://github.com/dashengju))
+ * Jungtaek Lim ([@HeartSaVioR](https://github.com/HeartSaVioR))
  


[12/23] storm git commit: change readme for storm-redis

Posted by bo...@apache.org.
change readme for storm-redis


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

Branch: refs/heads/master
Commit: d5267c7f9463df818ee2e6842341617448081741
Parents: 0f9438f
Author: dashengju <da...@qq.com>
Authored: Sun Jan 4 17:06:25 2015 +0800
Committer: dashengju <da...@qq.com>
Committed: Sun Jan 4 17:06:25 2015 +0800

----------------------------------------------------------------------
 external/storm-redis/README.md | 98 +++++++++++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/d5267c7f/external/storm-redis/README.md
----------------------------------------------------------------------
diff --git a/external/storm-redis/README.md b/external/storm-redis/README.md
index b8a1458..06f3940 100644
--- a/external/storm-redis/README.md
+++ b/external/storm-redis/README.md
@@ -17,6 +17,104 @@ use it as a maven dependency:
 </dependency>
 ```
 
+### AbstractRedisBolt usage:
+
+```java
+
+    public static class LookupWordTotalCountBolt extends AbstractRedisBolt {
+        private static final Logger LOG = LoggerFactory.getLogger(LookupWordTotalCountBolt.class);
+        private static final Random RANDOM = new Random();
+
+        public LookupWordTotalCountBolt(JedisPoolConfig config) {
+            super(config);
+        }
+
+        public LookupWordTotalCountBolt(JedisClusterConfig config) {
+            super(config);
+        }
+
+        @Override
+        public void execute(Tuple input) {
+            JedisCommands jedisCommands = null;
+            try {
+                jedisCommands = getInstance();
+                String wordName = input.getStringByField("word");
+                String countStr = jedisCommands.get(wordName);
+                if (countStr != null) {
+                    int count = Integer.parseInt(countStr);
+                    this.collector.emit(new Values(wordName, count));
+
+                    // print lookup result with low probability
+                    if(RANDOM.nextInt(1000) > 995) {
+                        LOG.info("Lookup result - word : " + wordName + " / count : " + count);
+                    }
+                } else {
+                    // skip
+                    LOG.warn("Word not found in Redis - word : " + wordName);
+                }
+            } finally {
+                if (jedisCommands != null) {
+                    returnInstance(jedisCommands);
+                }
+                this.collector.ack(input);
+            }
+        }
+
+        @Override
+        public void declareOutputFields(OutputFieldsDeclarer declarer) {
+            // wordName, count
+            declarer.declare(new Fields("wordName", "count"));
+        }
+    }
+
+```
+
+### Trident State usage
+
+1. RedisState and RedisMapState, which provide Jedis interface just for single redis.
+
+2. RedisClusterState and RedisClusterMapState, which provide JedisCluster interface, just for redis cluster.
+
+3. ShardedRedisState and ShardedRedisMapState, which provide ShardedJedis interface, but not implements now.
+
+RedisState
+```java
+        JedisPoolConfig poolConfig = new JedisPoolConfig.Builder()
+                                        .setHost(redisHost).setPort(redisPort)
+                                        .build();
+        TridentTupleMapper tupleMapper = new WordCountTupleMapper();
+        RedisState.Factory factory = new RedisState.Factory(poolConfig);
+
+        TridentTopology topology = new TridentTopology();
+        Stream stream = topology.newStream("spout1", spout);
+
+        stream.partitionPersist(factory,
+                                fields,
+                                new RedisStateUpdater("test_", tupleMapper, 86400000),
+                                new Fields());
+```
+
+RedisClusterState
+```java
+        Set<InetSocketAddress> nodes = new HashSet<InetSocketAddress>();
+        for (String hostPort : redisHostPort.split(",")) {
+            String[] host_port = hostPort.split(":");
+            nodes.add(new InetSocketAddress(host_port[0], Integer.valueOf(host_port[1])));
+        }
+        JedisClusterConfig clusterConfig = new JedisClusterConfig.Builder().setNodes(nodes)
+                                        .build();
+        TridentTupleMapper tupleMapper = new WordCountTupleMapper();
+        RedisClusterState.Factory factory = new RedisClusterState.Factory(clusterConfig);
+
+        TridentTopology topology = new TridentTopology();
+        Stream stream = topology.newStream("spout1", spout);
+
+        stream.partitionPersist(factory,
+                                fields,
+                                new RedisClusterStateUpdater("test_", tupleMapper, 86400000),
+                                new Fields());
+```
+
 ## License
 
 Licensed to the Apache Software Foundation (ASF) under one


[22/23] storm git commit: Merge branch 'branch_storm_redis' of https://github.com/dashengju/storm into STORM-609

Posted by bo...@apache.org.
Merge branch 'branch_storm_redis' of https://github.com/dashengju/storm into STORM-609

STORM-609: Add storm-redis to storm external


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

Branch: refs/heads/master
Commit: 240eb7c6a8155555c622ac5746e83c46dc2c16de
Parents: 9d0df23 c40c172
Author: Robert (Bobby) Evans <ev...@yahoo-inc.com>
Authored: Mon Feb 23 10:18:52 2015 -0600
Committer: Robert (Bobby) Evans <ev...@yahoo-inc.com>
Committed: Mon Feb 23 10:18:52 2015 -0600

----------------------------------------------------------------------
 external/storm-redis/LICENSE                    | 202 ++++++++++++
 external/storm-redis/README.md                  | 137 ++++++++
 external/storm-redis/pom.xml                    |  65 ++++
 .../storm/redis/bolt/AbstractRedisBolt.java     |  67 ++++
 .../trident/mapper/TridentTupleMapper.java      |  27 ++
 .../trident/state/RedisClusterMapState.java     | 294 +++++++++++++++++
 .../redis/trident/state/RedisClusterState.java  |  80 +++++
 .../trident/state/RedisClusterStateQuerier.java |  78 +++++
 .../trident/state/RedisClusterStateUpdater.java |  76 +++++
 .../redis/trident/state/RedisMapState.java      | 323 +++++++++++++++++++
 .../storm/redis/trident/state/RedisState.java   |  83 +++++
 .../redis/trident/state/RedisStateQuerier.java  |  70 ++++
 .../state/RedisStateSetCountQuerier.java        |  74 +++++
 .../trident/state/RedisStateSetUpdater.java     |  80 +++++
 .../redis/trident/state/RedisStateUpdater.java  |  75 +++++
 .../redis/util/config/JedisClusterConfig.java   |  82 +++++
 .../redis/util/config/JedisPoolConfig.java      |  97 ++++++
 .../util/container/JedisClusterContainer.java   |  47 +++
 .../JedisCommandsContainerBuilder.java          |  38 +++
 .../JedisCommandsInstanceContainer.java         |  25 ++
 .../redis/util/container/JedisContainer.java    |  65 ++++
 .../storm/redis/topology/LookupWordCount.java   | 127 ++++++++
 .../redis/topology/PersistentWordCount.java     | 117 +++++++
 .../storm/redis/topology/WordCounter.java       |  58 ++++
 .../apache/storm/redis/topology/WordSpout.java  |  88 +++++
 .../storm/redis/trident/PrintFunction.java      |  40 +++
 .../redis/trident/WordCountTridentRedis.java    |  97 ++++++
 .../trident/WordCountTridentRedisCluster.java   | 103 ++++++
 .../WordCountTridentRedisClusterMap.java        | 101 ++++++
 .../redis/trident/WordCountTridentRedisMap.java |  95 ++++++
 .../redis/trident/WordCountTupleMapper.java     |  16 +
 pom.xml                                         |   1 +
 32 files changed, 2928 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/240eb7c6/pom.xml
----------------------------------------------------------------------


[07/23] storm git commit: add License to all files

Posted by bo...@apache.org.
add License to all files


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

Branch: refs/heads/master
Commit: 06b01694125279358c10169d8f54110abe7da836
Parents: 980dcce
Author: dashengju <da...@qq.com>
Authored: Tue Dec 30 18:02:02 2014 +0800
Committer: dashengju <da...@qq.com>
Committed: Tue Dec 30 18:02:02 2014 +0800

----------------------------------------------------------------------
 external/storm-redis/README.md                     |  1 +
 .../apache/storm/redis/bolt/AbstractRedisBolt.java | 17 +++++++++++++++++
 .../redis/util/config/JedisClusterConfig.java      | 17 +++++++++++++++++
 .../storm/redis/util/config/JedisPoolConfig.java   | 17 +++++++++++++++++
 .../util/container/JedisClusterContainer.java      | 17 +++++++++++++++++
 .../container/JedisCommandsContainerBuilder.java   | 17 +++++++++++++++++
 .../container/JedisCommandsInstanceContainer.java  | 17 +++++++++++++++++
 .../storm/redis/util/container/JedisContainer.java | 17 +++++++++++++++++
 8 files changed, 120 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/06b01694/external/storm-redis/README.md
----------------------------------------------------------------------
diff --git a/external/storm-redis/README.md b/external/storm-redis/README.md
index dc68224..b8a1458 100644
--- a/external/storm-redis/README.md
+++ b/external/storm-redis/README.md
@@ -39,4 +39,5 @@ under the License.
 ## Committer Sponsors
 
  * DashengJu ([dashengju@gmail.com](mailto:dashengju@gmail.com))
+ * HeartSaVioR ([kabhwan@gmail.com](mailto:kabhwan@gmail.com))
  

http://git-wip-us.apache.org/repos/asf/storm/blob/06b01694/external/storm-redis/src/main/java/org/apache/storm/redis/bolt/AbstractRedisBolt.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/bolt/AbstractRedisBolt.java b/external/storm-redis/src/main/java/org/apache/storm/redis/bolt/AbstractRedisBolt.java
index 100503a..0b2a7f3 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/bolt/AbstractRedisBolt.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/bolt/AbstractRedisBolt.java
@@ -1,3 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.storm.redis.bolt;
 
 import backtype.storm.task.OutputCollector;

http://git-wip-us.apache.org/repos/asf/storm/blob/06b01694/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisClusterConfig.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisClusterConfig.java b/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisClusterConfig.java
index 9ec6b20..7d421b2 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisClusterConfig.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisClusterConfig.java
@@ -1,3 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.storm.redis.util.config;
 
 import com.google.common.base.Preconditions;

http://git-wip-us.apache.org/repos/asf/storm/blob/06b01694/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisPoolConfig.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisPoolConfig.java b/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisPoolConfig.java
index 21a79dd..9a42cf7 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisPoolConfig.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisPoolConfig.java
@@ -1,3 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.storm.redis.util.config;
 
 import redis.clients.jedis.Protocol;

http://git-wip-us.apache.org/repos/asf/storm/blob/06b01694/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisClusterContainer.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisClusterContainer.java b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisClusterContainer.java
index be6694a..5fd4115 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisClusterContainer.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisClusterContainer.java
@@ -1,3 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.storm.redis.util.container;
 
 import redis.clients.jedis.JedisCluster;

http://git-wip-us.apache.org/repos/asf/storm/blob/06b01694/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsContainerBuilder.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsContainerBuilder.java b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsContainerBuilder.java
index 1f10524..34fb5b1 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsContainerBuilder.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsContainerBuilder.java
@@ -1,3 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.storm.redis.util.container;
 
 import org.apache.storm.redis.util.config.JedisClusterConfig;

http://git-wip-us.apache.org/repos/asf/storm/blob/06b01694/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsInstanceContainer.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsInstanceContainer.java b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsInstanceContainer.java
index 6f1a148..847d6a5 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsInstanceContainer.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsInstanceContainer.java
@@ -1,3 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.storm.redis.util.container;
 
 import redis.clients.jedis.JedisCommands;

http://git-wip-us.apache.org/repos/asf/storm/blob/06b01694/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisContainer.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisContainer.java b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisContainer.java
index 58177e4..de9f1aa 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisContainer.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisContainer.java
@@ -1,3 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.storm.redis.util.container;
 
 import org.slf4j.Logger;


[04/23] storm git commit: Merge pull request #1 from HeartSaVioR/branch_storm_redis

Posted by bo...@apache.org.
Merge pull request #1 from HeartSaVioR/branch_storm_redis

storm-redis : Remove invalid exclusion

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

Branch: refs/heads/master
Commit: ac9719b05220d3a891d60e02f7120ba640230ef4
Parents: 5c357ff 28ebb82
Author: DashengJu <da...@gmail.com>
Authored: Tue Dec 30 10:02:59 2014 +0800
Committer: DashengJu <da...@gmail.com>
Committed: Tue Dec 30 10:02:59 2014 +0800

----------------------------------------------------------------------
 external/storm-redis/pom.xml | 10 ----------
 1 file changed, 10 deletions(-)
----------------------------------------------------------------------



[13/23] storm git commit: Merge pull request #3 from HeartSaVioR/storm_redis_apply_jedis_2_6_2

Posted by bo...@apache.org.
Merge pull request #3 from HeartSaVioR/storm_redis_apply_jedis_2_6_2

Bump up Jedis version to 2.6.2

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

Branch: refs/heads/master
Commit: 45b9a2efe0223c470fef9825cbabe038d28b0d2b
Parents: d5267c7 00e1bad
Author: DashengJu <da...@gmail.com>
Authored: Sun Jan 4 17:33:51 2015 +0800
Committer: DashengJu <da...@gmail.com>
Committed: Sun Jan 4 17:33:51 2015 +0800

----------------------------------------------------------------------
 external/storm-redis/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------



[15/23] storm git commit: Merge branch 'branch_storm_redis' of github.com:dashengju/storm into branch_storm_redis

Posted by bo...@apache.org.
Merge branch 'branch_storm_redis' of github.com:dashengju/storm into branch_storm_redis


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

Branch: refs/heads/master
Commit: b1a3396d725239bd801c11019e4968d20cb88e22
Parents: 780d91f 45b9a2e
Author: dashengju <da...@qq.com>
Authored: Sun Jan 4 17:36:24 2015 +0800
Committer: dashengju <da...@qq.com>
Committed: Sun Jan 4 17:36:24 2015 +0800

----------------------------------------------------------------------
 external/storm-redis/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------



[21/23] storm git commit: change committer sponsors members

Posted by bo...@apache.org.
change committer sponsors members


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

Branch: refs/heads/master
Commit: c40c1727799bc34073eaa5d56de4a5e7ffa773ff
Parents: 5daeb08
Author: dashengju <da...@qq.com>
Authored: Fri Feb 6 10:08:46 2015 +0800
Committer: dashengju <da...@qq.com>
Committed: Fri Feb 6 10:08:46 2015 +0800

----------------------------------------------------------------------
 external/storm-redis/README.md | 3 ---
 1 file changed, 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/c40c1727/external/storm-redis/README.md
----------------------------------------------------------------------
diff --git a/external/storm-redis/README.md b/external/storm-redis/README.md
index 8e6fbce..b01854f 100644
--- a/external/storm-redis/README.md
+++ b/external/storm-redis/README.md
@@ -135,6 +135,3 @@ under the License.
 ## Committer Sponsors
 
  * Robert Evans ([@revans2](https://github.com/revans2))
- * DashengJu ([@dashengju](https://github.com/dashengju))
- * Jungtaek Lim ([@HeartSaVioR](https://github.com/HeartSaVioR))
- 


[05/23] storm git commit: Introduce Basic Redis Bolt with some test topologies

Posted by bo...@apache.org.
Introduce Basic Redis Bolt with some test topologies


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

Branch: refs/heads/master
Commit: 171a8bf461a2fa97dcfa8439680f4043d1c2dd3a
Parents: 28ebb82
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Tue Dec 30 17:50:35 2014 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Tue Dec 30 17:50:35 2014 +0900

----------------------------------------------------------------------
 .../storm/redis/bolt/AbstractRedisBolt.java     |  50 +++++++
 .../redis/util/config/JedisClusterConfig.java   |  59 +++++++++
 .../redis/util/config/JedisPoolConfig.java      |  80 +++++++++++
 .../util/container/JedisClusterContainer.java   |  30 +++++
 .../JedisCommandsContainerBuilder.java          |  22 ++++
 .../JedisCommandsInstanceContainer.java         |   8 ++
 .../redis/util/container/JedisContainer.java    |  44 +++++++
 .../storm/redis/topology/LookupWordCount.java   | 131 +++++++++++++++++++
 .../redis/topology/PersistentWordCount.java     | 117 +++++++++++++++++
 .../storm/redis/topology/WordCounter.java       |  58 ++++++++
 .../apache/storm/redis/topology/WordSpout.java  |  88 +++++++++++++
 11 files changed, 687 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/171a8bf4/external/storm-redis/src/main/java/org/apache/storm/redis/bolt/AbstractRedisBolt.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/bolt/AbstractRedisBolt.java b/external/storm-redis/src/main/java/org/apache/storm/redis/bolt/AbstractRedisBolt.java
new file mode 100644
index 0000000..100503a
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/bolt/AbstractRedisBolt.java
@@ -0,0 +1,50 @@
+package org.apache.storm.redis.bolt;
+
+import backtype.storm.task.OutputCollector;
+import backtype.storm.task.TopologyContext;
+import backtype.storm.topology.base.BaseRichBolt;
+import org.apache.storm.redis.util.config.JedisClusterConfig;
+import org.apache.storm.redis.util.config.JedisPoolConfig;
+import org.apache.storm.redis.util.container.JedisCommandsContainerBuilder;
+import org.apache.storm.redis.util.container.JedisCommandsInstanceContainer;
+import redis.clients.jedis.JedisCommands;
+
+import java.util.Map;
+
+public abstract class AbstractRedisBolt extends BaseRichBolt {
+    protected OutputCollector collector;
+
+    private transient JedisCommandsInstanceContainer container;
+
+    private JedisPoolConfig jedisPoolConfig;
+    private JedisClusterConfig jedisClusterConfig;
+
+    public AbstractRedisBolt(JedisPoolConfig config) {
+        this.jedisPoolConfig = config;
+    }
+
+    public AbstractRedisBolt(JedisClusterConfig config) {
+        this.jedisClusterConfig = config;
+    }
+
+    @Override
+    public void prepare(Map map, TopologyContext topologyContext, OutputCollector collector) {
+        this.collector = collector;
+
+        if (jedisPoolConfig != null) {
+            this.container = JedisCommandsContainerBuilder.build(jedisPoolConfig);
+        } else if (jedisClusterConfig != null) {
+            this.container = JedisCommandsContainerBuilder.build(jedisClusterConfig);
+        } else {
+            throw new IllegalArgumentException("Jedis configuration not found");
+        }
+    }
+
+    protected JedisCommands getInstance() {
+        return this.container.getInstance();
+    }
+
+    protected void returnInstance(JedisCommands instance) {
+        this.container.returnInstance(instance);
+    }
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/171a8bf4/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisClusterConfig.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisClusterConfig.java b/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisClusterConfig.java
new file mode 100644
index 0000000..9ec6b20
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisClusterConfig.java
@@ -0,0 +1,59 @@
+package org.apache.storm.redis.util.config;
+
+import com.google.common.base.Preconditions;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.Protocol;
+
+import java.io.Serializable;
+import java.util.Set;
+
+public class JedisClusterConfig implements Serializable {
+    private Set<HostAndPort> nodes;
+    private int timeout;
+    private int maxRedirections;
+
+    public JedisClusterConfig(Set<HostAndPort> nodes, int timeout, int maxRedirections) {
+        this.nodes = nodes;
+        this.timeout = timeout;
+        this.maxRedirections = maxRedirections;
+    }
+
+    public Set<HostAndPort> getNodes() {
+        return nodes;
+    }
+
+    public int getTimeout() {
+        return timeout;
+    }
+
+    public int getMaxRedirections() {
+        return maxRedirections;
+    }
+
+    static class Builder {
+        private Set<HostAndPort> nodes;
+        private int timeout = Protocol.DEFAULT_TIMEOUT;
+        private int maxRedirections = 5;
+
+        public Builder setNodes(Set<HostAndPort> nodes) {
+            this.nodes = nodes;
+            return this;
+        }
+
+        public Builder setTimeout(int timeout) {
+            this.timeout = timeout;
+            return this;
+        }
+
+        public Builder setMaxRedirections(int maxRedirections) {
+            this.maxRedirections = maxRedirections;
+            return this;
+        }
+
+        public JedisClusterConfig build() {
+            Preconditions.checkNotNull(this.nodes, "Node information should be presented");
+
+            return new JedisClusterConfig(nodes, timeout, maxRedirections);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/171a8bf4/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisPoolConfig.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisPoolConfig.java b/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisPoolConfig.java
new file mode 100644
index 0000000..21a79dd
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/util/config/JedisPoolConfig.java
@@ -0,0 +1,80 @@
+package org.apache.storm.redis.util.config;
+
+import redis.clients.jedis.Protocol;
+
+import java.io.Serializable;
+
+public class JedisPoolConfig implements Serializable {
+    public static final String DEFAULT_HOST = "127.0.0.1";
+
+    private String host;
+    private int port;
+    private int timeout;
+    private int database;
+    private String password;
+
+    public JedisPoolConfig(String host, int port, int timeout, String password, int database) {
+        this.host = host;
+        this.port = port;
+        this.timeout = timeout;
+        this.database = database;
+        this.password = password;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public int getTimeout() {
+        return timeout;
+    }
+
+    public int getDatabase() {
+        return database;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public static class Builder {
+        private String host = DEFAULT_HOST;
+        private int port = Protocol.DEFAULT_PORT;
+        private int timeout = Protocol.DEFAULT_TIMEOUT;
+        private int database = Protocol.DEFAULT_DATABASE;
+        private String password;
+
+        public Builder setHost(String host) {
+            this.host = host;
+            return this;
+        }
+
+        public Builder setPort(int port) {
+            this.port = port;
+            return this;
+        }
+
+        public Builder setTimeout(int timeout) {
+            this.timeout = timeout;
+            return this;
+        }
+
+        public Builder setDatabase(int database) {
+            this.database = database;
+            return this;
+        }
+
+        public Builder setPassword(String password) {
+            this.password = password;
+            return this;
+        }
+
+        public JedisPoolConfig build() {
+            return new JedisPoolConfig(host, port, timeout, password, database);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/171a8bf4/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisClusterContainer.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisClusterContainer.java b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisClusterContainer.java
new file mode 100644
index 0000000..be6694a
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisClusterContainer.java
@@ -0,0 +1,30 @@
+package org.apache.storm.redis.util.container;
+
+import redis.clients.jedis.JedisCluster;
+import redis.clients.jedis.JedisCommands;
+
+import java.io.Closeable;
+
+public class JedisClusterContainer implements JedisCommandsInstanceContainer, Closeable {
+
+    private JedisCluster jedisCluster;
+
+    public JedisClusterContainer(JedisCluster jedisCluster) {
+        this.jedisCluster = jedisCluster;
+    }
+
+    @Override
+    public JedisCommands getInstance() {
+        return this.jedisCluster;
+    }
+
+    @Override
+    public void returnInstance(JedisCommands jedisCommands) {
+        // do nothing
+    }
+
+    @Override
+    public void close() {
+        this.jedisCluster.close();
+    }
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/171a8bf4/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsContainerBuilder.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsContainerBuilder.java b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsContainerBuilder.java
new file mode 100644
index 0000000..1f10524
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsContainerBuilder.java
@@ -0,0 +1,22 @@
+package org.apache.storm.redis.util.container;
+
+import org.apache.storm.redis.util.config.JedisClusterConfig;
+import org.apache.storm.redis.util.config.JedisPoolConfig;
+import redis.clients.jedis.JedisCluster;
+import redis.clients.jedis.JedisPool;
+
+public class JedisCommandsContainerBuilder {
+
+    // TODO : serialize redis.clients.jedis.JedisPoolConfig
+    public static final redis.clients.jedis.JedisPoolConfig DEFAULT_POOL_CONFIG = new redis.clients.jedis.JedisPoolConfig();
+
+    public static JedisCommandsInstanceContainer build(JedisPoolConfig config) {
+        JedisPool jedisPool = new JedisPool(DEFAULT_POOL_CONFIG, config.getHost(), config.getPort(), config.getTimeout(), config.getPassword(), config.getDatabase());
+        return new JedisContainer(jedisPool);
+    }
+
+    public static JedisCommandsInstanceContainer build(JedisClusterConfig config) {
+        JedisCluster jedisCluster = new JedisCluster(config.getNodes(), config.getTimeout(), config.getMaxRedirections(), DEFAULT_POOL_CONFIG);
+        return new JedisClusterContainer(jedisCluster);
+    }
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/171a8bf4/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsInstanceContainer.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsInstanceContainer.java b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsInstanceContainer.java
new file mode 100644
index 0000000..6f1a148
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsInstanceContainer.java
@@ -0,0 +1,8 @@
+package org.apache.storm.redis.util.container;
+
+import redis.clients.jedis.JedisCommands;
+
+public interface JedisCommandsInstanceContainer {
+    JedisCommands getInstance();
+    void returnInstance(JedisCommands jedisCommands);
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/171a8bf4/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisContainer.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisContainer.java b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisContainer.java
new file mode 100644
index 0000000..58177e4
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisContainer.java
@@ -0,0 +1,44 @@
+package org.apache.storm.redis.util.container;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.JedisCommands;
+import redis.clients.jedis.JedisPool;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+public class JedisContainer implements JedisCommandsInstanceContainer, Closeable {
+    private static final Logger LOG = LoggerFactory.getLogger(JedisContainer.class);
+
+    private JedisPool jedisPool;
+
+    public JedisContainer(JedisPool jedisPool) {
+        this.jedisPool = jedisPool;
+    }
+
+    @Override
+    public JedisCommands getInstance() {
+        return jedisPool.getResource();
+    }
+
+    @Override
+    public void returnInstance(JedisCommands jedisCommands) {
+        try {
+            ((Closeable) jedisCommands).close();
+        } catch (IOException e) {
+            LOG.warn("Failed to close (return) instance to pool");
+            try {
+                jedisPool.returnBrokenResource((Jedis) jedisCommands);
+            } catch (Exception e2) {
+                LOG.error("Failed to discard instance from pool");
+            }
+        }
+    }
+
+    @Override
+    public void close() {
+        jedisPool.close();
+    }
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/171a8bf4/external/storm-redis/src/test/java/org/apache/storm/redis/topology/LookupWordCount.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/test/java/org/apache/storm/redis/topology/LookupWordCount.java b/external/storm-redis/src/test/java/org/apache/storm/redis/topology/LookupWordCount.java
new file mode 100644
index 0000000..42d3800
--- /dev/null
+++ b/external/storm-redis/src/test/java/org/apache/storm/redis/topology/LookupWordCount.java
@@ -0,0 +1,131 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.topology;
+
+import backtype.storm.Config;
+import backtype.storm.LocalCluster;
+import backtype.storm.StormSubmitter;
+import backtype.storm.topology.OutputFieldsDeclarer;
+import backtype.storm.topology.TopologyBuilder;
+import backtype.storm.tuple.Fields;
+import backtype.storm.tuple.Tuple;
+import backtype.storm.tuple.Values;
+import org.apache.storm.redis.bolt.AbstractRedisBolt;
+import org.apache.storm.redis.util.config.JedisClusterConfig;
+import org.apache.storm.redis.util.config.JedisPoolConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import redis.clients.jedis.JedisCommands;
+import redis.clients.jedis.exceptions.JedisConnectionException;
+import redis.clients.jedis.exceptions.JedisException;
+
+import java.util.Random;
+
+public class LookupWordCount {
+    private static final String WORD_SPOUT = "WORD_SPOUT";
+    private static final String LOOKUP_BOLT = "LOOKUP_BOLT";
+
+    private static final String TEST_REDIS_HOST = "127.0.0.1";
+    private static final int TEST_REDIS_PORT = 6379;
+
+    public static class LookupWordTotalCountBolt extends AbstractRedisBolt {
+        private static final Logger LOG = LoggerFactory.getLogger(LookupWordTotalCountBolt.class);
+        private static final Random RANDOM = new Random();
+
+        public LookupWordTotalCountBolt(JedisPoolConfig config) {
+            super(config);
+        }
+
+        public LookupWordTotalCountBolt(JedisClusterConfig config) {
+            super(config);
+        }
+
+        @Override
+        public void execute(Tuple input) {
+            JedisCommands jedisCommands = null;
+            try {
+                jedisCommands = getInstance();
+                String wordName = input.getStringByField("word");
+                String countStr = jedisCommands.get(wordName);
+                if (countStr != null) {
+                    int count = Integer.parseInt(countStr);
+                    this.collector.emit(new Values(wordName, count));
+
+                    // print lookup result with low probability
+                    if(RANDOM.nextInt(1000) > 995) {
+                        LOG.info("Lookup result - word : " + wordName + " / count : " + count);
+                    }
+                } else {
+                    // skip
+                    LOG.warn("Word not found in Redis - word : " + wordName);
+                }
+            } catch (NumberFormatException e) {
+                LOG.error("Counter Type seems not stored to integer", e);
+            } catch (JedisConnectionException e) {
+                throw new RuntimeException("Unfortunately, this test requires redis-server running", e);
+            } catch (JedisException e) {
+                LOG.error("Exception occurred from Jedis/Redis", e);
+            } finally {
+                returnInstance(jedisCommands);
+                this.collector.ack(input);
+            }
+        }
+
+        @Override
+        public void declareOutputFields(OutputFieldsDeclarer declarer) {
+            // wordName, count
+            declarer.declare(new Fields("wordName", "count"));
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        Config config = new Config();
+
+        String host = TEST_REDIS_HOST;
+        int port = TEST_REDIS_PORT;
+
+        if (args.length > 2) {
+            host = args[0];
+            port = Integer.parseInt(args[1]);
+        }
+
+        JedisPoolConfig poolConfig = new JedisPoolConfig.Builder()
+                .setHost(host).setPort(port).build();
+
+        WordSpout spout = new WordSpout();
+        LookupWordTotalCountBolt redisLookupBolt = new LookupWordTotalCountBolt(poolConfig);
+
+        //wordspout -> lookupbolt
+        TopologyBuilder builder = new TopologyBuilder();
+        builder.setSpout(WORD_SPOUT, spout, 1);
+        builder.setBolt(LOOKUP_BOLT, redisLookupBolt, 1).shuffleGrouping(WORD_SPOUT);
+
+        if (args.length == 2) {
+            LocalCluster cluster = new LocalCluster();
+            cluster.submitTopology("test", config, builder.createTopology());
+            Thread.sleep(30000);
+            cluster.killTopology("test");
+            cluster.shutdown();
+            System.exit(0);
+        } else if (args.length == 3) {
+            StormSubmitter.submitTopology(args[2], config, builder.createTopology());
+        } else{
+            System.out.println("Usage: LookupWordCount <redis host> <redis port> (topology name)");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/171a8bf4/external/storm-redis/src/test/java/org/apache/storm/redis/topology/PersistentWordCount.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/test/java/org/apache/storm/redis/topology/PersistentWordCount.java b/external/storm-redis/src/test/java/org/apache/storm/redis/topology/PersistentWordCount.java
new file mode 100644
index 0000000..a96696b
--- /dev/null
+++ b/external/storm-redis/src/test/java/org/apache/storm/redis/topology/PersistentWordCount.java
@@ -0,0 +1,117 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.topology;
+
+import backtype.storm.Config;
+import backtype.storm.LocalCluster;
+import backtype.storm.StormSubmitter;
+import backtype.storm.topology.OutputFieldsDeclarer;
+import backtype.storm.topology.TopologyBuilder;
+import backtype.storm.tuple.Fields;
+import backtype.storm.tuple.Tuple;
+import org.apache.storm.redis.bolt.AbstractRedisBolt;
+import org.apache.storm.redis.util.config.JedisClusterConfig;
+import org.apache.storm.redis.util.config.JedisPoolConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import redis.clients.jedis.JedisCommands;
+import redis.clients.jedis.exceptions.JedisConnectionException;
+import redis.clients.jedis.exceptions.JedisException;
+
+public class PersistentWordCount {
+    private static final String WORD_SPOUT = "WORD_SPOUT";
+    private static final String COUNT_BOLT = "COUNT_BOLT";
+    private static final String REDIS_BOLT = "REDIS_BOLT";
+
+    private static final String TEST_REDIS_HOST = "127.0.0.1";
+    private static final int TEST_REDIS_PORT = 6379;
+
+    public static class StoreCountRedisBolt extends AbstractRedisBolt {
+        private static final Logger LOG = LoggerFactory.getLogger(StoreCountRedisBolt.class);
+
+        public StoreCountRedisBolt(JedisPoolConfig config) {
+            super(config);
+        }
+
+        public StoreCountRedisBolt(JedisClusterConfig config) {
+            super(config);
+        }
+
+        @Override
+        public void execute(Tuple input) {
+            String word = input.getStringByField("word");
+            int count = input.getIntegerByField("count");
+
+            JedisCommands commands = null;
+            try {
+                commands = getInstance();
+                commands.incrBy(word, count);
+            } catch (JedisConnectionException e) {
+                throw new RuntimeException("Unfortunately, this test requires redis-server running", e);
+            } catch (JedisException e) {
+                LOG.error("Exception occurred from Jedis/Redis", e);
+            } finally {
+                returnInstance(commands);
+                this.collector.ack(input);
+            }
+        }
+
+        @Override
+        public void declareOutputFields(OutputFieldsDeclarer declarer) {
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        Config config = new Config();
+
+        String host = TEST_REDIS_HOST;
+        int port = TEST_REDIS_PORT;
+
+        if (args.length > 2) {
+            host = args[0];
+            port = Integer.parseInt(args[1]);
+        }
+
+        JedisPoolConfig poolConfig = new JedisPoolConfig.Builder()
+                .setHost(host).setPort(port).build();
+
+        WordSpout spout = new WordSpout();
+        WordCounter bolt = new WordCounter();
+        StoreCountRedisBolt redisBolt = new StoreCountRedisBolt(poolConfig);
+
+        // wordSpout ==> countBolt ==> RedisBolt
+        TopologyBuilder builder = new TopologyBuilder();
+
+        builder.setSpout(WORD_SPOUT, spout, 1);
+        builder.setBolt(COUNT_BOLT, bolt, 1).shuffleGrouping(WORD_SPOUT);
+        builder.setBolt(REDIS_BOLT, redisBolt, 1).fieldsGrouping(COUNT_BOLT, new Fields("word"));
+
+        if (args.length == 2) {
+            LocalCluster cluster = new LocalCluster();
+            cluster.submitTopology("test", config, builder.createTopology());
+            Thread.sleep(30000);
+            cluster.killTopology("test");
+            cluster.shutdown();
+            System.exit(0);
+        } else if (args.length == 3) {
+            StormSubmitter.submitTopology(args[2], config, builder.createTopology());
+        } else {
+            System.out.println("Usage: PersistentWordCount <redis host> <redis port> (topology name)");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/171a8bf4/external/storm-redis/src/test/java/org/apache/storm/redis/topology/WordCounter.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/test/java/org/apache/storm/redis/topology/WordCounter.java b/external/storm-redis/src/test/java/org/apache/storm/redis/topology/WordCounter.java
new file mode 100644
index 0000000..6a0548d
--- /dev/null
+++ b/external/storm-redis/src/test/java/org/apache/storm/redis/topology/WordCounter.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.topology;
+
+import backtype.storm.task.TopologyContext;
+import backtype.storm.topology.BasicOutputCollector;
+import backtype.storm.topology.IBasicBolt;
+import backtype.storm.topology.OutputFieldsDeclarer;
+import backtype.storm.tuple.Fields;
+import backtype.storm.tuple.Tuple;
+
+import java.util.Map;
+
+import static backtype.storm.utils.Utils.tuple;
+
+public class WordCounter implements IBasicBolt {
+
+
+    @SuppressWarnings("rawtypes")
+    public void prepare(Map stormConf, TopologyContext context) {
+    }
+
+    /*
+     * Just output the word value with a count of 1.
+     */
+    public void execute(Tuple input, BasicOutputCollector collector) {
+        collector.emit(tuple(input.getValues().get(0), 1));
+    }
+
+    public void cleanup() {
+
+    }
+
+    public void declareOutputFields(OutputFieldsDeclarer declarer) {
+        declarer.declare(new Fields("word", "count"));
+    }
+
+    @Override
+    public Map<String, Object> getComponentConfiguration() {
+        return null;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/storm/blob/171a8bf4/external/storm-redis/src/test/java/org/apache/storm/redis/topology/WordSpout.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/test/java/org/apache/storm/redis/topology/WordSpout.java b/external/storm-redis/src/test/java/org/apache/storm/redis/topology/WordSpout.java
new file mode 100644
index 0000000..bb9c2d7
--- /dev/null
+++ b/external/storm-redis/src/test/java/org/apache/storm/redis/topology/WordSpout.java
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.topology;
+
+import backtype.storm.spout.SpoutOutputCollector;
+import backtype.storm.task.TopologyContext;
+import backtype.storm.topology.IRichSpout;
+import backtype.storm.topology.OutputFieldsDeclarer;
+import backtype.storm.tuple.Fields;
+import backtype.storm.tuple.Values;
+
+import java.util.Map;
+import java.util.Random;
+import java.util.UUID;
+
+public class WordSpout implements IRichSpout {
+    boolean isDistributed;
+    SpoutOutputCollector collector;
+    public static final String[] words = new String[] { "apple", "orange", "pineapple", "banana", "watermelon" };
+
+    public WordSpout() {
+        this(true);
+    }
+
+    public WordSpout(boolean isDistributed) {
+        this.isDistributed = isDistributed;
+    }
+
+    public boolean isDistributed() {
+        return this.isDistributed;
+    }
+
+    @SuppressWarnings("rawtypes")
+    public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
+        this.collector = collector;
+    }
+
+    public void close() {
+
+    }
+
+    public void nextTuple() {
+        final Random rand = new Random();
+        final String word = words[rand.nextInt(words.length)];
+        this.collector.emit(new Values(word), UUID.randomUUID());
+        Thread.yield();
+    }
+
+    public void ack(Object msgId) {
+
+    }
+
+    public void fail(Object msgId) {
+
+    }
+
+    public void declareOutputFields(OutputFieldsDeclarer declarer) {
+        declarer.declare(new Fields("word"));
+    }
+
+    @Override
+    public void activate() {
+    }
+
+    @Override
+    public void deactivate() {
+    }
+
+    @Override
+    public Map<String, Object> getComponentConfiguration() {
+        return null;
+    }
+}


[14/23] storm git commit: Merge branch 'master' of github.com:apache/storm into branch_storm_redis

Posted by bo...@apache.org.
Merge branch 'master' of github.com:apache/storm into branch_storm_redis


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

Branch: refs/heads/master
Commit: 780d91f29fc1025b3fa6591aa69022001bfd5331
Parents: d5267c7 ab76e67
Author: dashengju <da...@qq.com>
Authored: Sun Jan 4 17:35:56 2015 +0800
Committer: dashengju <da...@qq.com>
Committed: Sun Jan 4 17:35:56 2015 +0800

----------------------------------------------------------------------
 CHANGELOG.md                                                    | 1 +
 .../java/org/apache/storm/hdfs/bolt/format/SequenceFormat.java  | 5 ++---
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------



[08/23] storm git commit: change implements of trident state use JedisCommands

Posted by bo...@apache.org.
change implements of trident state use JedisCommands


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

Branch: refs/heads/master
Commit: b2c0731401f99859d454c4a2cd6b54cc9e5a4c96
Parents: 06b0169
Author: dashengju <da...@qq.com>
Authored: Wed Dec 31 13:47:01 2014 +0800
Committer: dashengju <da...@qq.com>
Committed: Wed Dec 31 13:47:01 2014 +0800

----------------------------------------------------------------------
 external/storm-redis/pom.xml                    |   5 +
 .../trident/state/RedisClusterMapState.java     | 237 -------
 .../redis/trident/state/RedisClusterState.java  | 190 ------
 .../state/RedisClusterStateSetCountQuerier.java |  66 --
 .../state/RedisClusterStateSetUpdater.java      |  72 ---
 .../redis/trident/state/RedisMapState.java      | 625 +++++++++++--------
 .../trident/state/RedisMapStateExample.java     | 101 ---
 .../storm/redis/trident/state/RedisState.java   |  90 +++
 .../redis/trident/state/RedisStateQuerier.java  |  74 +++
 .../state/RedisStateSetCountQuerier.java        |  71 +++
 .../trident/state/RedisStateSetUpdater.java     |  77 +++
 .../redis/trident/state/RedisStateUpdater.java  |  73 +++
 12 files changed, 758 insertions(+), 923 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/b2c07314/external/storm-redis/pom.xml
----------------------------------------------------------------------
diff --git a/external/storm-redis/pom.xml b/external/storm-redis/pom.xml
index 3f89ffc..46c20a5 100644
--- a/external/storm-redis/pom.xml
+++ b/external/storm-redis/pom.xml
@@ -33,6 +33,11 @@
             <name>Dasheng Ju</name>
             <email>dashengju@gmail.com</email>
         </developer>
+        <developer>
+            <id>HeartSaVioR</id>
+            <name>Jungtaek Lim</name>
+            <email>kabhwan@gmail.com</email>
+        </developer>
     </developers>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/storm/blob/b2c07314/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
deleted file mode 100644
index b062a53..0000000
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterMapState.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.storm.redis.trident.state;
-
-import backtype.storm.task.IMetricsContext;
-import backtype.storm.tuple.Values;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import redis.clients.jedis.HostAndPort;
-import redis.clients.jedis.JedisCluster;
-import redis.clients.jedis.Protocol;
-import storm.trident.state.JSONNonTransactionalSerializer;
-import storm.trident.state.JSONOpaqueSerializer;
-import storm.trident.state.JSONTransactionalSerializer;
-import storm.trident.state.OpaqueValue;
-import storm.trident.state.Serializer;
-import storm.trident.state.State;
-import storm.trident.state.StateFactory;
-import storm.trident.state.StateType;
-import storm.trident.state.TransactionalValue;
-import storm.trident.state.map.CachedMap;
-import storm.trident.state.map.IBackingMap;
-import storm.trident.state.map.MapState;
-import storm.trident.state.map.NonTransactionalMap;
-import storm.trident.state.map.OpaqueMap;
-import storm.trident.state.map.SnapshottableMap;
-import storm.trident.state.map.TransactionalMap;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.EnumMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public class RedisClusterMapState<T> implements IBackingMap<T> {
-    private static final Logger logger = LoggerFactory.getLogger(RedisClusterMapState.class);
-
-    private static final EnumMap<StateType, Serializer> DEFAULT_SERIALIZERS = Maps.newEnumMap(ImmutableMap.of(
-            StateType.NON_TRANSACTIONAL, new JSONNonTransactionalSerializer(),
-            StateType.TRANSACTIONAL, new JSONTransactionalSerializer(),
-            StateType.OPAQUE, new JSONOpaqueSerializer()
-    ));
-
-    public static class DefaultKeyFactory implements KeyFactory {
-        public String build(List<Object> key) {
-            if (key.size() != 1)
-                throw new RuntimeException("Default KeyFactory does not support compound keys");
-            return (String) key.get(0);
-        }
-    };
-
-    public static class Options<T> implements Serializable {
-        public int localCacheSize = 1000;
-        public String globalKey = "$REDIS-MAP-STATE-GLOBAL";
-        public Serializer<T> serializer = null;
-        public KeyFactory keyFactory = null;
-        public int connectionTimeout = Protocol.DEFAULT_TIMEOUT;
-        public int maxRedirections = 10;
-        public String password = null;
-        public int database = Protocol.DEFAULT_DATABASE;
-    }
-
-    public static interface KeyFactory extends Serializable {
-        String build(List<Object> key);
-    }
-
-    public static StateFactory opaque(Set<HostAndPort> clusterNodes) {
-        return opaque(clusterNodes, new Options());
-    }
-
-    public static StateFactory opaque(Set<HostAndPort> clusterNodes, Options<OpaqueValue> opts) {
-        return opaque(clusterNodes, opts, new DefaultKeyFactory());
-    }
-
-    public static StateFactory opaque(Set<HostAndPort> clusterNodes, Options<OpaqueValue> opts, KeyFactory factory) {
-        return new Factory(clusterNodes, StateType.OPAQUE, opts, factory);
-    }
-
-    public static StateFactory transactional(Set<HostAndPort> clusterNodes) {
-        return transactional(clusterNodes, new Options());
-    }
-
-    public static StateFactory transactional(Set<HostAndPort> clusterNodes, Options<TransactionalValue> opts) {
-        return transactional(clusterNodes, opts, new DefaultKeyFactory());
-    }
-
-    public static StateFactory transactional(Set<HostAndPort> clusterNodes, Options<TransactionalValue> opts, KeyFactory factory) {
-        return new Factory(clusterNodes, StateType.TRANSACTIONAL, opts, factory);
-    }
-
-    public static StateFactory nonTransactional(Set<HostAndPort> clusterNodes) {
-        return nonTransactional(clusterNodes, new Options());
-    }
-
-    public static StateFactory nonTransactional(Set<HostAndPort> clusterNodes, Options<Object> opts) {
-        return nonTransactional(clusterNodes, opts, new DefaultKeyFactory());
-    }
-
-    public static StateFactory nonTransactional(Set<HostAndPort> clusterNodes, Options<Object> opts, KeyFactory factory) {
-        return new Factory(clusterNodes, StateType.NON_TRANSACTIONAL, opts, factory);
-    }
-
-    protected static class Factory implements StateFactory {
-        StateType type;
-        Set<HostAndPort> clusterNodes;
-        Serializer serializer;
-        KeyFactory factory;
-        Options options;
-
-        public Factory(Set<HostAndPort> clusterNodes, StateType type, Options options, KeyFactory factory) {
-            this.type = type;
-            this.clusterNodes = clusterNodes;
-            this.options = options;
-            this.factory = factory;
-
-            if (options.serializer == null) {
-                serializer = DEFAULT_SERIALIZERS.get(type);
-                if (serializer == null) {
-                    throw new RuntimeException("Couldn't find serializer for state type: " + type);
-                }
-            } else {
-                this.serializer = options.serializer;
-            }
-        }
-
-        public State makeState(@SuppressWarnings("rawtypes") Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
-            JedisCluster jc = new JedisCluster(clusterNodes, options.connectionTimeout, options.maxRedirections);
-            RedisClusterMapState state = new RedisClusterMapState(jc, options, serializer, factory);
-            CachedMap c = new CachedMap(state, options.localCacheSize);
-
-            MapState ms;
-            if (type == StateType.NON_TRANSACTIONAL) {
-                ms = NonTransactionalMap.build(c);
-
-            } else if (type == StateType.OPAQUE) {
-                ms = OpaqueMap.build(c);
-
-            } else if (type == StateType.TRANSACTIONAL) {
-                ms = TransactionalMap.build(c);
-
-            } else {
-                throw new RuntimeException("Unknown state type: " + type);
-            }
-
-            return new SnapshottableMap(ms, new Values(options.globalKey));
-        }
-    }
-
-    private final JedisCluster jedisCluster;
-    private Options options;
-    private Serializer serializer;
-    private KeyFactory keyFactory;
-
-    public RedisClusterMapState(JedisCluster jedisCluster, Options options, Serializer<T> serializer, KeyFactory keyFactory) {
-        this.jedisCluster = jedisCluster;
-        this.options = options;
-        this.serializer = serializer;
-        this.keyFactory = keyFactory;
-    }
-
-    public List<T> multiGet(List<List<Object>> keys) {
-        if (keys.size() == 0) {
-            return Collections.emptyList();
-        }
-
-        String[] stringKeys = buildKeys(keys);
-        List<String> values = mget(stringKeys);
-        return deserializeValues(keys, values);
-    }
-
-    private List<T> deserializeValues(List<List<Object>> keys, List<String> values) {
-        List<T> result = new ArrayList<T>(keys.size());
-        for (String value : values) {
-            if (value != null) {
-                result.add((T) serializer.deserialize(value.getBytes()));
-            } else {
-                result.add(null);
-            }
-        }
-        return result;
-    }
-
-    private String[] buildKeys(List<List<Object>> keys) {
-        String[] stringKeys = new String[keys.size()];
-        int index = 0;
-        for (List<Object> key : keys)
-            stringKeys[index++] = keyFactory.build(key);
-        return stringKeys;
-    }
-
-    private List<String> mget(String... keys) {
-        List<String> rets = new ArrayList<String>();
-        for (String key : keys) {
-            rets.add(jedisCluster.get(key));
-        }
-        return rets;
-    }
-
-    public void multiPut(List<List<Object>> keys, List<T> vals) {
-        if (keys.size() == 0) {
-            return;
-        }
-        if (keys.size() != vals.size()) {
-            logger.error("multiPut keys.size[" + keys.size() + "] not equal to vals.size[" + vals.size() + "]");
-            return;
-        }
-
-        /**
-         * Todo: because JedisCluster now not support mset, we use for,set to implement multiPut
-         * */
-        for (int i = 0; i < keys.size(); i++) {
-            String redisKey = keyFactory.build(keys.get(i));
-            String val = new String(serializer.serialize(vals.get(i)));
-            jedisCluster.set(redisKey, val);
-        }
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/storm/blob/b2c07314/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
deleted file mode 100644
index 9ebc87d..0000000
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterState.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.storm.redis.trident.state;
-
-import backtype.storm.task.IMetricsContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import redis.clients.jedis.HostAndPort;
-import redis.clients.jedis.JedisCluster;
-import redis.clients.jedis.Protocol;
-import storm.trident.state.State;
-import storm.trident.state.StateFactory;
-
-import java.io.Serializable;
-import java.net.InetSocketAddress;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public class RedisClusterState implements State {
-    private static final Logger logger = LoggerFactory.getLogger(RedisClusterState.class);
-
-    @Override
-    public void beginCommit(Long aLong) {
-    }
-
-    @Override
-    public void commit(Long aLong) {
-    }
-
-    public static class Options implements Serializable {
-        public int connectionTimeout = Protocol.DEFAULT_TIMEOUT;
-        public int maxRedirections = 10;
-    }
-
-    public static class Factory implements StateFactory {
-        Set<InetSocketAddress> clusterNodes;
-        Options options;
-
-        public Factory(Set<InetSocketAddress> clusterNodes, Options options) {
-            this.clusterNodes = clusterNodes;
-            this.options = options;
-        }
-
-        public State makeState(@SuppressWarnings("rawtypes") Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
-            Set<HostAndPort> nodes = new HashSet<HostAndPort>();
-            for (InetSocketAddress addr : clusterNodes) {
-                nodes.add(new HostAndPort(addr.getHostName(), addr.getPort()));
-            }
-            JedisCluster jc = new JedisCluster(nodes, options.connectionTimeout, options.maxRedirections);
-            return new RedisClusterState(jc, options);
-        }
-    }
-
-    private final JedisCluster jedisCluster;
-    private Options options;
-
-    public RedisClusterState(JedisCluster jedisCluster, Options options) {
-        this.jedisCluster = jedisCluster;
-        this.options = options;
-    }
-
-    /**
-     * Set a timeout on the specified key. After the timeout the key will be
-     * automatically deleted by the server. A key with an associated timeout is
-     * said to be volatile in Redis terminology.
-     * <p>
-     * Voltile keys are stored on disk like the other keys, the timeout is
-     * persistent too like all the other aspects of the dataset. Saving a
-     * dataset containing expires and stopping the server does not stop the flow
-     * of time as Redis stores on disk the time when the key will no longer be
-     * available as Unix time, and not the remaining seconds.
-     * <p>
-     * Since Redis 2.1.3 you can update the value of the timeout of a key
-     * already having an expire set. It is also possible to undo the expire at
-     * all turning the key into a normal key using the {@link #persist(String)
-     * PERSIST} command.
-     * <p>
-     * Time complexity: O(1)
-     *
-     * @see <ahref="http://code.google.com/p/redis/wiki/ExpireCommand">ExpireCommand</a>
-     *
-     * @param key
-     * @param seconds
-     * @return Integer reply, specifically: 1: the timeout was set. 0: the
-     *         timeout was not set since the key already has an associated
-     *         timeout (this may happen only in Redis versions < 2.1.3, Redis >=
-     *         2.1.3 will happily update the timeout), or the key does not
-     *         exist.
-     */
-    public Long expire(final String key, final int seconds) {
-        return jedisCluster.expire(key, seconds);
-    }
-
-    /**
-     * EXPIREAT works exctly like {@link #expire(String, int) EXPIRE} but
-     * instead to get the number of seconds representing the Time To Live of the
-     * key as a second argument (that is a relative way of specifing the TTL),
-     * it takes an absolute one in the form of a UNIX timestamp (Number of
-     * seconds elapsed since 1 Gen 1970).
-     * <p>
-     * EXPIREAT was introduced in order to implement the Append Only File
-     * persistence mode so that EXPIRE commands are automatically translated
-     * into EXPIREAT commands for the append only file. Of course EXPIREAT can
-     * also used by programmers that need a way to simply specify that a given
-     * key should expire at a given time in the future.
-     * <p>
-     * Since Redis 2.1.3 you can update the value of the timeout of a key
-     * already having an expire set. It is also possible to undo the expire at
-     * all turning the key into a normal key using the {@link #persist(String)
-     * PERSIST} command.
-     * <p>
-     * Time complexity: O(1)
-     *
-     * @see <ahref="http://code.google.com/p/redis/wiki/ExpireCommand">ExpireCommand</a>
-     *
-     * @param key
-     * @param unixTime
-     * @return Integer reply, specifically: 1: the timeout was set. 0: the
-     *         timeout was not set since the key already has an associated
-     *         timeout (this may happen only in Redis versions < 2.1.3, Redis >=
-     *         2.1.3 will happily update the timeout), or the key does not
-     *         exist.
-     */
-    public Long expireAt(final String key, final long unixTime) {
-        return jedisCluster.expireAt(key, unixTime);
-    }
-
-    /**
-     * Undo a {@link #expire(String, int) expire} at turning the expire key into
-     * a normal key.
-     * <p>
-     * Time complexity: O(1)
-     *
-     * @param key
-     * @return Integer reply, specifically: 1: the key is now persist. 0: the
-     *         key is not persist (only happens when key not set).
-     */
-    public Long persist(final String key) {
-        return jedisCluster.persist(key);
-    }
-
-    public Long sadd(final String key, final String... member) {
-        return jedisCluster.sadd(key, member);
-    }
-
-    public Set<String> smembers(final String key) {
-        return jedisCluster.smembers(key);
-    }
-
-    public Long srem(final String key, final String... member) {
-        return jedisCluster.srem(key, member);
-    }
-
-    public String spop(final String key) {
-        return jedisCluster.spop(key);
-    }
-
-    public Long scard(final String key) {
-        return jedisCluster.scard(key);
-    }
-
-    public Boolean sismember(final String key, final String member) {
-        return jedisCluster.sismember(key, member);
-    }
-
-    public String srandmember(final String key) {
-        return jedisCluster.srandmember(key);
-    }
-
-    public List<String> srandmember(final String key, final int count) {
-        return jedisCluster.srandmember(key, count);
-    }
-}

http://git-wip-us.apache.org/repos/asf/storm/blob/b2c07314/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateSetCountQuerier.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateSetCountQuerier.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateSetCountQuerier.java
deleted file mode 100644
index 03a9375..0000000
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateSetCountQuerier.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.storm.redis.trident.state;
-
-import backtype.storm.tuple.Values;
-import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import storm.trident.operation.TridentCollector;
-import storm.trident.state.BaseQueryFunction;
-import storm.trident.tuple.TridentTuple;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by judasheng on 14-12-12.
- */
-public class RedisClusterStateSetCountQuerier extends BaseQueryFunction<RedisClusterState, Long> {
-    private static final Logger logger = LoggerFactory.getLogger(RedisClusterState.class);
-
-    private final String redisKeyPrefix;
-    private final TridentTupleMapper tupleMapper;
-
-    public RedisClusterStateSetCountQuerier(String redisKeyPrefix, TridentTupleMapper tupleMapper) {
-        this.redisKeyPrefix = redisKeyPrefix;
-        this.tupleMapper = tupleMapper;
-    }
-
-    @Override
-    public List<Long> batchRetrieve(RedisClusterState redisClusterState, List<TridentTuple> inputs) {
-        List<Long> ret = new ArrayList<Long>();
-        for(TridentTuple input: inputs) {
-            String key = this.tupleMapper.getKeyFromTridentTuple(input);
-            if (redisKeyPrefix != null && redisKeyPrefix.length() > 0) {
-                key = redisKeyPrefix + key;
-            }
-            long count = redisClusterState.scard(key);
-            ret.add(count);
-
-            logger.debug("RedisClusterStateSetCountQuerier key[" + key + "] count[" + count + "]");
-        }
-        return ret;
-    }
-
-    @Override
-    public void execute(TridentTuple tuple, Long s, TridentCollector collector) {
-        String key = this.tupleMapper.getKeyFromTridentTuple(tuple);
-        collector.emit(new Values(key, s));
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/storm/blob/b2c07314/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateSetUpdater.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateSetUpdater.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateSetUpdater.java
deleted file mode 100644
index a41ab64..0000000
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisClusterStateSetUpdater.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.storm.redis.trident.state;
-
-import backtype.storm.tuple.Values;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import storm.trident.operation.TridentCollector;
-import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
-import storm.trident.state.BaseStateUpdater;
-import storm.trident.tuple.TridentTuple;
-
-import java.util.List;
-
-/**
- * Created by judasheng on 14-12-12.
- */
-public class RedisClusterStateSetUpdater extends BaseStateUpdater<RedisClusterState> {
-    private static final Logger logger = LoggerFactory.getLogger(RedisClusterState.class);
-
-    private static final long DEFAULT_EXPIRE_INTERVAL_MS = 86400000;
-
-    private final String redisKeyPrefix;
-    private final TridentTupleMapper tupleMapper;
-    private final long expireIntervalMs;
-
-    public RedisClusterStateSetUpdater(String redisKeyPrefix, TridentTupleMapper tupleMapper, long expireIntervalMs) {
-        this.redisKeyPrefix = redisKeyPrefix;
-        this.tupleMapper = tupleMapper;
-        if (expireIntervalMs > 0) {
-            this.expireIntervalMs = expireIntervalMs;
-        } else {
-            this.expireIntervalMs = DEFAULT_EXPIRE_INTERVAL_MS;
-        }
-    }
-
-    @Override
-    public void updateState(RedisClusterState redisClusterState, List<TridentTuple> inputs,
-                            TridentCollector collector) {
-        long expireAt = System.currentTimeMillis() + expireIntervalMs;
-        for (TridentTuple input : inputs) {
-            String key = this.tupleMapper.getKeyFromTridentTuple(input);
-            String redisKey = key;
-            if (redisKeyPrefix != null && redisKeyPrefix.length() > 0) {
-                redisKey = redisKeyPrefix + redisKey;
-            }
-            String value = this.tupleMapper.getValueFromTridentTuple(input);
-
-            logger.debug("RedisClusterStateSetUpdater key[" + key + "] redisKey[" + redisKey + "] value[" + value + "]");
-            redisClusterState.sadd(redisKey, value);
-            redisClusterState.expireAt(redisKey, expireAt);
-            Long count = redisClusterState.scard(redisKey);
-
-            collector.emit(new Values(key, count));
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/storm/blob/b2c07314/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
index 049a663..647167e 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
@@ -21,14 +21,16 @@ import backtype.storm.task.IMetricsContext;
 import backtype.storm.tuple.Values;
 import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
+import org.apache.storm.redis.util.config.JedisClusterConfig;
+import org.apache.storm.redis.util.config.JedisPoolConfig;
+import org.apache.storm.redis.util.container.JedisCommandsContainerBuilder;
+import org.apache.storm.redis.util.container.JedisCommandsInstanceContainer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import redis.clients.jedis.Jedis;
-import redis.clients.jedis.JedisPool;
-import redis.clients.jedis.JedisPoolConfig;
-import redis.clients.jedis.Pipeline;
-import redis.clients.jedis.Protocol;
+import redis.clients.jedis.JedisCommands;
 import storm.trident.state.JSONNonTransactionalSerializer;
 import storm.trident.state.JSONOpaqueSerializer;
 import storm.trident.state.JSONTransactionalSerializer;
@@ -47,7 +49,6 @@ import storm.trident.state.map.SnapshottableMap;
 import storm.trident.state.map.TransactionalMap;
 
 import java.io.Serializable;
-import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.EnumMap;
@@ -55,260 +56,370 @@ import java.util.List;
 import java.util.Map;
 
 public class RedisMapState<T> implements IBackingMap<T> {
-   private static final Logger logger = LoggerFactory.getLogger(RedisMapState.class);
-
-   private static final EnumMap<StateType, Serializer> DEFAULT_SERIALIZERS = Maps.newEnumMap(ImmutableMap.of(
-         StateType.NON_TRANSACTIONAL, new JSONNonTransactionalSerializer(),
-         StateType.TRANSACTIONAL, new JSONTransactionalSerializer(),
-         StateType.OPAQUE, new JSONOpaqueSerializer()
-   ));
-
-   public static class DefaultKeyFactory implements KeyFactory {
-      public String build(List<Object> key) {
-         if (key.size() != 1)
-            throw new RuntimeException("Default KeyFactory does not support compound keys");
-         return (String) key.get(0);
-      }
-   };
-
-   public static class Options<T> implements Serializable {
-      public int localCacheSize = 1000;
-      public String globalKey = "$REDIS-MAP-STATE-GLOBAL";
-      public Serializer<T> serializer = null;
-      public KeyFactory keyFactory = null;
-      public int connectionTimeout = Protocol.DEFAULT_TIMEOUT;
-      public String password = null;
-      public int database = Protocol.DEFAULT_DATABASE;
-      public String hkey = null;
-   }
-
-   public static interface KeyFactory extends Serializable {
-      String build(List<Object> key);
-   }
-
-   public static StateFactory opaque(InetSocketAddress server) {
-      return opaque(server, new Options());
-   }
-
-   public static StateFactory opaque(InetSocketAddress server, String hkey) {
-      Options opts = new Options();
-      opts.hkey = hkey;
-      return opaque(server, opts);
-   }
-
-   public static StateFactory opaque(InetSocketAddress server, Options<OpaqueValue> opts) {
-      return opaque(server, opts, new DefaultKeyFactory());
-   }
-
-   public static StateFactory opaque(InetSocketAddress server, Options<OpaqueValue> opts, KeyFactory factory) {
-      return new Factory(server, StateType.OPAQUE, opts, factory);
-   }
-
-   public static StateFactory transactional(InetSocketAddress server) {
-      return transactional(server, new Options());
-   }
-
-   public static StateFactory transactional(InetSocketAddress server, String hkey) {
-      Options opts = new Options();
-      opts.hkey = hkey;
-      return transactional(server, opts);
-   }
-
-   public static StateFactory transactional(InetSocketAddress server, Options<TransactionalValue> opts) {
-      return transactional(server, opts, new DefaultKeyFactory());
-   }
-
-   public static StateFactory transactional(InetSocketAddress server, Options<TransactionalValue> opts, KeyFactory factory) {
-      return new Factory(server, StateType.TRANSACTIONAL, opts, factory);
-   }
-
-   public static StateFactory nonTransactional(InetSocketAddress server) {
-      return nonTransactional(server, new Options());
-   }
-
-   public static StateFactory nonTransactional(InetSocketAddress server, String hkey) {
-      Options opts = new Options();
-      opts.hkey = hkey;
-      return nonTransactional(server, opts);
-   }
-
-   public static StateFactory nonTransactional(InetSocketAddress server, Options<Object> opts) {
-      return nonTransactional(server, opts, new DefaultKeyFactory());
-   }
-
-   public static StateFactory nonTransactional(InetSocketAddress server, Options<Object> opts, KeyFactory factory) {
-      return new Factory(server, StateType.NON_TRANSACTIONAL, opts, factory);
-   }
-
-   protected static class Factory implements StateFactory {
-      StateType type;
-      InetSocketAddress server;
-      Serializer serializer;
-      KeyFactory factory;
-      Options options;
-
-      public Factory(InetSocketAddress server, StateType type, Options options, KeyFactory factory) {
-         this.type = type;
-         this.server = server;
-         this.options = options;
-         this.factory = factory;
-
-         if (options.serializer == null) {
-            serializer = DEFAULT_SERIALIZERS.get(type);
-            if (serializer == null) {
-               throw new RuntimeException("Couldn't find serializer for state type: " + type);
+    private static final Logger logger = LoggerFactory.getLogger(RedisMapState.class);
+
+    private static final EnumMap<StateType, Serializer> DEFAULT_SERIALIZERS = Maps.newEnumMap(ImmutableMap.of(
+            StateType.NON_TRANSACTIONAL, new JSONNonTransactionalSerializer(),
+            StateType.TRANSACTIONAL, new JSONTransactionalSerializer(),
+            StateType.OPAQUE, new JSONOpaqueSerializer()
+    ));
+
+    public static class DefaultKeyFactory implements KeyFactory {
+        public String build(List<Object> key) {
+            if (key.size() != 1)
+                throw new RuntimeException("Default KeyFactory does not support compound keys");
+            return (String) key.get(0);
+        }
+    };
+
+    public static class Options<T> implements Serializable {
+        public int localCacheSize = 1000;
+        public String globalKey = "$REDIS-MAP-STATE-GLOBAL";
+        KeyFactory keyFactory = null;
+        public Serializer<T> serializer = null;
+        public String hkey = null;
+    }
+
+    public static interface KeyFactory extends Serializable {
+        String build(List<Object> key);
+    }
+
+    /**
+     * OpaqueTransactional for redis.
+     * */
+    public static StateFactory opaque(JedisPoolConfig jedisPoolConfig) {
+        return opaque(jedisPoolConfig, new Options());
+    }
+
+    public static StateFactory opaque(JedisPoolConfig jedisPoolConfig, String hkey) {
+        Options opts = new Options();
+        opts.hkey = hkey;
+        return opaque(jedisPoolConfig, opts);
+    }
+
+    public static StateFactory opaque(JedisPoolConfig jedisPoolConfig,  KeyFactory factory) {
+        Options opts = new Options();
+        opts.keyFactory = factory;
+        return opaque(jedisPoolConfig, opts);
+    }
+
+    public static StateFactory opaque(JedisPoolConfig jedisPoolConfig, Options<OpaqueValue> opts) {
+        return new Factory(jedisPoolConfig, StateType.OPAQUE, opts);
+    }
+
+    /**
+     * OpaqueTransactional for redis-cluster.
+     * */
+    public static StateFactory opaque(JedisClusterConfig jedisClusterConfig) {
+        return opaque(jedisClusterConfig, new Options());
+    }
+
+    public static StateFactory opaque(JedisClusterConfig jedisClusterConfig, String hkey) {
+        Options opts = new Options();
+        opts.hkey = hkey;
+        return opaque(jedisClusterConfig, opts);
+    }
+
+    public static StateFactory opaque(JedisClusterConfig jedisClusterConfig, KeyFactory factory) {
+        Options opts = new Options();
+        opts.keyFactory = factory;
+        return opaque(jedisClusterConfig, opts);
+    }
+
+    public static StateFactory opaque(JedisClusterConfig jedisClusterConfig, Options<OpaqueValue> opts) {
+        return new Factory(jedisClusterConfig, StateType.OPAQUE, opts);
+    }
+
+    /**
+     * Transactional for redis.
+     * */
+    public static StateFactory transactional(JedisPoolConfig jedisPoolConfig) {
+        return transactional(jedisPoolConfig, new Options());
+    }
+
+    public static StateFactory transactional(JedisPoolConfig jedisPoolConfig, String hkey) {
+        Options opts = new Options();
+        opts.hkey = hkey;
+        return transactional(jedisPoolConfig, opts);
+    }
+
+    public static StateFactory transactional(JedisPoolConfig jedisPoolConfig, KeyFactory factory) {
+        Options opts = new Options();
+        opts.keyFactory = factory;
+        return transactional(jedisPoolConfig, opts);
+    }
+
+    public static StateFactory transactional(JedisPoolConfig jedisPoolConfig, Options<TransactionalValue> opts) {
+        return new Factory(jedisPoolConfig, StateType.TRANSACTIONAL, opts);
+    }
+
+    /**
+     * Transactional for redis-cluster.
+     * */
+    public static StateFactory transactional(JedisClusterConfig jedisClusterConfig) {
+        return transactional(jedisClusterConfig, new Options());
+    }
+
+    public static StateFactory transactional(JedisClusterConfig jedisClusterConfig, String hkey) {
+        Options opts = new Options();
+        opts.hkey = hkey;
+        return transactional(jedisClusterConfig, opts);
+    }
+
+    public static StateFactory transactional(JedisClusterConfig jedisClusterConfig, KeyFactory factory) {
+        Options opts = new Options();
+        opts.keyFactory = factory;
+        return transactional(jedisClusterConfig, opts);
+    }
+
+    public static StateFactory transactional(JedisClusterConfig jedisClusterConfig, Options<TransactionalValue> opts) {
+        return new Factory(jedisClusterConfig, StateType.TRANSACTIONAL, opts);
+    }
+
+    /**
+     * NonTransactional for redis.
+     * */
+    public static StateFactory nonTransactional(JedisPoolConfig jedisPoolConfig) {
+        return nonTransactional(jedisPoolConfig, new Options());
+    }
+
+    public static StateFactory nonTransactional(JedisPoolConfig jedisPoolConfig, String hkey) {
+        Options opts = new Options();
+        opts.hkey = hkey;
+        return nonTransactional(jedisPoolConfig, opts);
+    }
+
+    public static StateFactory nonTransactional(JedisPoolConfig jedisPoolConfig, KeyFactory factory) {
+        Options opts = new Options();
+        opts.keyFactory = factory;
+        return nonTransactional(jedisPoolConfig, opts);
+    }
+
+    public static StateFactory nonTransactional(JedisPoolConfig jedisPoolConfig, Options<Object> opts) {
+        return new Factory(jedisPoolConfig, StateType.NON_TRANSACTIONAL, opts);
+    }
+
+    /**
+     * NonTransactional for redis-cluster.
+     * */
+    public static StateFactory nonTransactional(JedisClusterConfig jedisClusterConfig) {
+        return nonTransactional(jedisClusterConfig, new Options());
+    }
+
+    public static StateFactory nonTransactional(JedisClusterConfig jedisClusterConfig, String hkey) {
+        Options opts = new Options();
+        opts.hkey = hkey;
+        return nonTransactional(jedisClusterConfig, opts);
+    }
+
+    public static StateFactory nonTransactional(JedisClusterConfig jedisClusterConfig, KeyFactory factory) {
+        Options opts = new Options();
+        opts.keyFactory = factory;
+        return nonTransactional(jedisClusterConfig, opts);
+    }
+
+    public static StateFactory nonTransactional(JedisClusterConfig jedisClusterConfig, Options<Object> opts) {
+        return new Factory(jedisClusterConfig, StateType.NON_TRANSACTIONAL, opts);
+    }
+
+
+
+    protected static class Factory implements StateFactory {
+        JedisPoolConfig jedisPoolConfig;
+        JedisClusterConfig jedisClusterConfig;
+
+        StateType type;
+        Serializer serializer;
+        KeyFactory keyFactory;
+        Options options;
+
+        public Factory(JedisPoolConfig jedisPoolConfig, StateType type, Options options) {
+            this.jedisPoolConfig = jedisPoolConfig;
+            this.type = type;
+            this.options = options;
+
+            this.keyFactory = options.keyFactory;
+            if (this.keyFactory == null) {
+                this.keyFactory = new DefaultKeyFactory();
             }
-         } else {
             this.serializer = options.serializer;
-         }
-      }
-
-      public State makeState(@SuppressWarnings("rawtypes") Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
-         JedisPool pool = new JedisPool(new JedisPoolConfig(),
-                    server.getHostName(), server.getPort(),
-                    options.connectionTimeout,
-                    options.password,
-                    options.database);
-         RedisMapState state = new RedisMapState(pool, options, serializer, factory);
-         CachedMap c = new CachedMap(state, options.localCacheSize);
-
-         MapState ms;
-         if (type == StateType.NON_TRANSACTIONAL) {
-            ms = NonTransactionalMap.build(c);
-
-         } else if (type == StateType.OPAQUE) {
-            ms = OpaqueMap.build(c);
-
-         } else if (type == StateType.TRANSACTIONAL) {
-            ms = TransactionalMap.build(c);
-
-         } else {
-            throw new RuntimeException("Unknown state type: " + type);
-         }
-
-         return new SnapshottableMap(ms, new Values(options.globalKey));
-      }
-   }
-
-   private final JedisPool pool;
-   private Options options;
-   private Serializer serializer;
-   private KeyFactory keyFactory;
-
-   public RedisMapState(JedisPool pool, Options options, Serializer<T> serializer, KeyFactory keyFactory) {
-      this.pool = pool;
-      this.options = options;
-      this.serializer = serializer;
-      this.keyFactory = keyFactory;
-   }
-
-   public List<T> multiGet(List<List<Object>> keys) {
-      if (keys.size() == 0) {
-         return Collections.emptyList();
-      }
-      if (Strings.isNullOrEmpty(this.options.hkey)) {
-         String[] stringKeys = buildKeys(keys);
-         List<String> values = mget(stringKeys);
-         return deserializeValues(keys, values);
-      } else {
-         Map<byte[], byte[]> keyValue = hgetAll(this.options.hkey.getBytes());
-         List<String> values = buildValuesFromMap(keys, keyValue);
-         return deserializeValues(keys, values);
-      }
-   }
-
-   private List<String> buildValuesFromMap(List<List<Object>> keys, Map<byte[], byte[]> keyValue) {
-      List<String> values = new ArrayList<String>(keys.size());
-      for (List<Object> key : keys) {
-         String strKey = keyFactory.build(key);
-         byte[] bytes = keyValue.get(strKey.getBytes());
-         values.add(new String(bytes));
-      }
-      return values;
-   }
-
-   private List<T> deserializeValues(List<List<Object>> keys, List<String> values) {
-      List<T> result = new ArrayList<T>(keys.size());
-      for (String value : values) {
-         if (value != null) {
-            result.add((T) serializer.deserialize(value.getBytes()));
-         } else {
-            result.add(null);
-         }
-      }
-      return result;
-   }
-
-   private String[] buildKeys(List<List<Object>> keys) {
-      String[] stringKeys = new String[keys.size()];
-      int index = 0;
-      for (List<Object> key : keys)
-         stringKeys[index++] = keyFactory.build(key);
-      return stringKeys;
-   }
-
-   private List<String> mget(String... keys) {
-      Jedis jedis = pool.getResource();
-      try {
-         return jedis.mget(keys);
-      } finally {
-         pool.returnResource(jedis);
-      }
-   }
-
-   private Map<byte[], byte[]> hgetAll(byte[] bytes) {
-      Jedis jedis = pool.getResource();
-      try {
-         return jedis.hgetAll(bytes);
-      } finally {
-         pool.returnResource(jedis);
-      }
-   }
-
-   public void multiPut(List<List<Object>> keys, List<T> vals) {
-      if (keys.size() == 0) {
-         return;
-      }
-
-      if (Strings.isNullOrEmpty(this.options.hkey)) {
-         String[] keyValues = buildKeyValuesList(keys, vals);
-         mset(keyValues);
-      } else {
-         Jedis jedis = pool.getResource();
-         try {
-            Pipeline pl = jedis.pipelined();
-            pl.multi();
-
-            for (int i = 0; i < keys.size(); i++) {
-               String val = new String(serializer.serialize(vals.get(i)));
-               pl.hset(this.options.hkey,
-                     keyFactory.build(keys.get(i)),
-                     val);
+            if (this.serializer == null) {
+                this.serializer = DEFAULT_SERIALIZERS.get(type);
+                if (this.serializer == null) {
+                    throw new RuntimeException("Couldn't find serializer for state type: " + type);
+                }
             }
+        }
 
-            pl.exec();
-            pl.sync();
-         } finally {
-            pool.returnResource(jedis);
-         }
-      }
-   }
-
-   private String[] buildKeyValuesList(List<List<Object>> keys, List<T> vals) {
-      String[] keyValues = new String[keys.size() * 2];
-      for (int i = 0; i < keys.size(); i++) {
-         keyValues[i * 2] = keyFactory.build(keys.get(i));
-         keyValues[i * 2 + 1] = new String(serializer.serialize(vals.get(i)));
-      }
-      return keyValues;
-   }
-
-   private void mset(String... keyValues) {
-      Jedis jedis = pool.getResource();
-      try {
-         jedis.mset(keyValues);
-      } finally {
-         pool.returnResource(jedis);
-      }
-   }
+        public Factory(JedisClusterConfig jedisClusterConfig, StateType type, Options options) {
+            this.jedisClusterConfig = jedisClusterConfig;
+            this.type = type;
+            this.options = options;
+
+            this.keyFactory = options.keyFactory;
+            if (this.keyFactory == null) {
+                this.keyFactory = new DefaultKeyFactory();
+            }
+            this.serializer = options.serializer;
+            if (this.serializer == null) {
+                this.serializer = DEFAULT_SERIALIZERS.get(type);
+                if (this.serializer == null) {
+                    throw new RuntimeException("Couldn't find serializer for state type: " + type);
+                }
+            }
+        }
+
+        public State makeState(@SuppressWarnings("rawtypes") Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
+            JedisCommandsInstanceContainer container;
+            if (jedisPoolConfig != null) {
+                container = JedisCommandsContainerBuilder.build(jedisPoolConfig);
+            } else if (jedisClusterConfig != null) {
+                container = JedisCommandsContainerBuilder.build(jedisClusterConfig);
+            } else {
+                throw new IllegalArgumentException("Jedis configuration not found");
+            }
+            RedisMapState state = new RedisMapState(container, options, serializer, keyFactory);
+            CachedMap c = new CachedMap(state, options.localCacheSize);
+
+            MapState ms;
+            if (type == StateType.NON_TRANSACTIONAL) {
+                ms = NonTransactionalMap.build(c);
+
+            } else if (type == StateType.OPAQUE) {
+                ms = OpaqueMap.build(c);
+
+            } else if (type == StateType.TRANSACTIONAL) {
+                ms = TransactionalMap.build(c);
+
+            } else {
+                throw new RuntimeException("Unknown state type: " + type);
+            }
+
+            return new SnapshottableMap(ms, new Values(options.globalKey));
+        }
+    }
+
+    private transient JedisCommandsInstanceContainer container;
+    private Options options;
+    private Serializer serializer;
+    private KeyFactory keyFactory;
+
+    public RedisMapState(JedisCommandsInstanceContainer container, Options options,
+                                            Serializer<T> serializer, KeyFactory keyFactory) {
+        this.container = container;
+        this.options = options;
+        this.serializer = serializer;
+        this.keyFactory = keyFactory;
+    }
+
+    public List<T> multiGet(List<List<Object>> keys) {
+        if (keys.size() == 0) {
+            return Collections.emptyList();
+        }
+        if (Strings.isNullOrEmpty(this.options.hkey)) {
+            String[] stringKeys = buildKeys(keys);
+            List<String> values = Lists.newArrayList();
+
+            JedisCommands jedisCommands = container.getInstance();
+            try {
+                if (jedisCommands instanceof Jedis) {
+                    //Todo because jedisCommands not support mget, we use Jedis for mget if it is Jedis
+                    values = ((Jedis)jedisCommands).mget(stringKeys);
+                } else {
+                    for (String stringKey : stringKeys) {
+                        String value = jedisCommands.get(stringKey);
+                        values.add(value);
+                    }
+                }
+            } finally {
+                container.returnInstance(jedisCommands);
+            }
+
+            return deserializeValues(keys, values);
+        } else {
+            JedisCommands jedisCommands = container.getInstance();
+            try {
+                Map<String, String> keyValue = jedisCommands.hgetAll(this.options.hkey);
+                List<String> values = buildValuesFromMap(keys, keyValue);
+                return deserializeValues(keys, values);
+            } finally {
+                container.returnInstance(jedisCommands);
+            }
+        }
+    }
+
+    private List<String> buildValuesFromMap(List<List<Object>> keys, Map<String, String> keyValue) {
+        List<String> values = new ArrayList<String>(keys.size());
+        for (List<Object> key : keys) {
+            String strKey = keyFactory.build(key);
+            String value = keyValue.get(strKey);
+            values.add(value);
+        }
+        return values;
+    }
+
+    private List<T> deserializeValues(List<List<Object>> keys, List<String> values) {
+        List<T> result = new ArrayList<T>(keys.size());
+        for (String value : values) {
+            if (value != null) {
+                result.add((T) serializer.deserialize(value.getBytes()));
+            } else {
+                result.add(null);
+            }
+        }
+        return result;
+    }
+
+    private String[] buildKeys(List<List<Object>> keys) {
+        String[] stringKeys = new String[keys.size()];
+        int index = 0;
+        for (List<Object> key : keys)
+            stringKeys[index++] = keyFactory.build(key);
+        return stringKeys;
+    }
+
+    public void multiPut(List<List<Object>> keys, List<T> vals) {
+        if (keys.size() == 0) {
+            return;
+        }
+
+        if (Strings.isNullOrEmpty(this.options.hkey)) {
+            JedisCommands jedisCommands = container.getInstance();
+            try {
+                if (jedisCommands instanceof Jedis) {
+                    //Todo because jedisCommands not support mget, we use Jedis for mget if it is Jedis
+                    String[] keyValue = buildKeyValuesList(keys, vals);
+                    ((Jedis)jedisCommands).mset(keyValue);
+                } else {
+                    for (int i = 0; i < keys.size(); i++) {
+                        String val = new String(serializer.serialize(vals.get(i)));
+                        String redisKey = keyFactory.build(keys.get(i));
+                        jedisCommands.set(redisKey, val);
+                    }
+                }
+            } finally {
+                container.returnInstance(jedisCommands);
+            }
+        } else {
+            JedisCommands jedisCommands = container.getInstance();
+            try {
+                for (int i = 0; i < keys.size(); i++) {
+                    String val = new String(serializer.serialize(vals.get(i)));
+                    String redisKey = keyFactory.build(keys.get(i));
+                    jedisCommands.hset(this.options.hkey, redisKey, val);
+                }
+            } finally {
+                container.returnInstance(jedisCommands);
+            }
+        }
+    }
+
+    private String[] buildKeyValuesList(List<List<Object>> keys, List<T> vals) {
+        String[] keyValues = new String[keys.size() * 2];
+        for (int i = 0; i < keys.size(); i++) {
+            keyValues[i * 2] = keyFactory.build(keys.get(i));
+            keyValues[i * 2 + 1] = new String(serializer.serialize(vals.get(i)));
+        }
+        return keyValues;
+    }
 }

http://git-wip-us.apache.org/repos/asf/storm/blob/b2c07314/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapStateExample.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapStateExample.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapStateExample.java
deleted file mode 100644
index 8fa784a..0000000
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapStateExample.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.storm.redis.trident.state;
-
-import backtype.storm.Config;
-import backtype.storm.LocalCluster;
-import backtype.storm.LocalDRPC;
-import backtype.storm.generated.StormTopology;
-import backtype.storm.tuple.Fields;
-import backtype.storm.tuple.Values;
-import backtype.storm.utils.Utils;
-import redis.clients.jedis.exceptions.JedisConnectionException;
-import storm.trident.TridentState;
-import storm.trident.TridentTopology;
-import storm.trident.operation.BaseFunction;
-import storm.trident.operation.TridentCollector;
-import storm.trident.operation.builtin.Count;
-import storm.trident.operation.builtin.FilterNull;
-import storm.trident.operation.builtin.MapGet;
-import storm.trident.operation.builtin.Sum;
-import storm.trident.state.StateFactory;
-import storm.trident.testing.FixedBatchSpout;
-import storm.trident.tuple.TridentTuple;
-
-import java.net.InetSocketAddress;
-
-public class RedisMapStateExample {
-
-	public static class Split extends BaseFunction {
-		@Override
-		public void execute(TridentTuple tuple, TridentCollector collector) {
-			String sentence = tuple.getString(0);
-			for (String word : sentence.split(" ")) {
-				collector.emit(new Values(word));
-			}
-		}
-	}
-
-	public static StormTopology buildTopology(LocalDRPC drpc, StateFactory state) {
-		FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 3,
-				new Values("the cow jumped over the moon"), 
-				new Values("the man went to the store and bought some candy"),
-				new Values("four score and seven years ago"), 
-				new Values("how many apples can you eat"), 
-				new Values("to be or not to be the person"));
-		spout.setCycle(true);
-
-		TridentTopology topology = new TridentTopology();
-		TridentState wordCounts = topology.newStream("spout1", spout)
-				.each(new Fields("sentence"), new Split(), new Fields("word"))
-				.groupBy(new Fields("word"))
-				.persistentAggregate(state, new Count(), new Fields("count"))
-				.parallelismHint(6);
-
-		topology.newDRPCStream("words", drpc)
-				.each(new Fields("args"), new Split(), new Fields("word"))
-				.groupBy(new Fields("word"))
-				.stateQuery(wordCounts, new Fields("word"), new MapGet(),
-						new Fields("count"))
-				.each(new Fields("count"), new FilterNull())
-				.aggregate(new Fields("count"), new Sum(), new Fields("sum"));
-
-		return topology.build();
-	}
-
-	public static void main(String[] args) {
-		StateFactory redis = RedisMapState.nonTransactional(new InetSocketAddress("localhost", 6379));
-
-		LocalDRPC drpc = new LocalDRPC();
-		StormTopology topology = buildTopology(drpc, redis);
-		Config conf = new Config();
-		LocalCluster cluster = new LocalCluster();
-		cluster.submitTopology("tester", conf, topology);
-
-		try {
-			for (int i = 0; i < 100; i++) {
-				System.out.println("DRPC: " + drpc.execute("words", "cat the man four"));
-				Utils.sleep(1000);
-			}
-			
-		} catch (JedisConnectionException e) {
-			throw new RuntimeException("Unfortunately, this test requires redis-server runing on localhost:6379", e);
-		}
-
-	}
-}

http://git-wip-us.apache.org/repos/asf/storm/blob/b2c07314/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisState.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisState.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisState.java
new file mode 100644
index 0000000..47d2a28
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisState.java
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident.state;
+
+import backtype.storm.task.IMetricsContext;
+import org.apache.storm.redis.util.config.JedisClusterConfig;
+import org.apache.storm.redis.util.config.JedisPoolConfig;
+import org.apache.storm.redis.util.container.JedisCommandsContainerBuilder;
+import org.apache.storm.redis.util.container.JedisCommandsInstanceContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import redis.clients.jedis.JedisCommands;
+import storm.trident.state.State;
+import storm.trident.state.StateFactory;
+
+import java.util.Map;
+
+public class RedisState implements State {
+    private static final Logger logger = LoggerFactory.getLogger(RedisState.class);
+
+    @Override
+    public void beginCommit(Long aLong) {
+    }
+
+    @Override
+    public void commit(Long aLong) {
+    }
+
+    public static class Factory implements StateFactory {
+        private JedisPoolConfig jedisPoolConfig;
+        private JedisClusterConfig jedisClusterConfig;
+
+        public Factory(JedisPoolConfig config) {
+            this.jedisPoolConfig = config;
+        }
+
+        public Factory(JedisClusterConfig config) {
+            this.jedisClusterConfig = config;
+        }
+
+        public State makeState(@SuppressWarnings("rawtypes") Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
+            JedisCommandsInstanceContainer container;
+            if (jedisPoolConfig != null) {
+                container = JedisCommandsContainerBuilder.build(jedisPoolConfig);
+            } else if (jedisClusterConfig != null) {
+                container = JedisCommandsContainerBuilder.build(jedisClusterConfig);
+            } else {
+                throw new IllegalArgumentException("Jedis configuration not found");
+            }
+
+            return new RedisState(container);
+        }
+    }
+
+    private transient JedisCommandsInstanceContainer container;
+
+    public RedisState(JedisCommandsInstanceContainer container) {
+        this.container = container;
+    }
+
+    /**
+     * The state updater and querier can get a JedisCommands instance
+     * */
+    public JedisCommands getInstance() {
+        return this.container.getInstance();
+    }
+
+    /**
+     * The state updater and querier return the JedisCommands instance
+     * */
+    public void returnInstance(JedisCommands instance) {
+        this.container.returnInstance(instance);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/b2c07314/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateQuerier.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateQuerier.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateQuerier.java
new file mode 100644
index 0000000..e01f8b8
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateQuerier.java
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident.state;
+
+import backtype.storm.tuple.Values;
+import com.google.common.collect.Lists;
+import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import redis.clients.jedis.JedisCommands;
+import storm.trident.operation.TridentCollector;
+import storm.trident.state.BaseQueryFunction;
+import storm.trident.tuple.TridentTuple;
+
+import java.util.List;
+
+/**
+ * Created by judasheng on 14-12-12.
+ */
+public class RedisStateQuerier extends BaseQueryFunction<RedisState, String> {
+    private static final Logger logger = LoggerFactory.getLogger(RedisState.class);
+
+    private final String redisKeyPrefix;
+    private final TridentTupleMapper tupleMapper;
+
+    public RedisStateQuerier(String redisKeyPrefix, TridentTupleMapper tupleMapper) {
+        this.redisKeyPrefix = redisKeyPrefix;
+        this.tupleMapper = tupleMapper;
+    }
+
+    @Override
+    public List<String> batchRetrieve(RedisState redisState, List<TridentTuple> inputs) {
+        List<String> ret = Lists.newArrayList();
+
+        JedisCommands jedisCommands = redisState.getInstance();
+        try {
+            for (TridentTuple input : inputs) {
+                String key = this.tupleMapper.getKeyFromTridentTuple(input);
+                if (redisKeyPrefix != null && redisKeyPrefix.length() > 0) {
+                    key = redisKeyPrefix + key;
+                }
+                String value = jedisCommands.get(key);
+                ret.add(value);
+
+                logger.debug("redis get key[" + key + "] count[" + value + "]");
+            }
+        } finally {
+            redisState.returnInstance(jedisCommands);
+        }
+
+        return ret;
+    }
+
+    @Override
+    public void execute(TridentTuple tuple, String s, TridentCollector collector) {
+        String key = this.tupleMapper.getKeyFromTridentTuple(tuple);
+        collector.emit(new Values(key, s));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/storm/blob/b2c07314/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetCountQuerier.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetCountQuerier.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetCountQuerier.java
new file mode 100644
index 0000000..506f1b1
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetCountQuerier.java
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident.state;
+
+import backtype.storm.tuple.Values;
+import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import redis.clients.jedis.JedisCommands;
+import storm.trident.operation.TridentCollector;
+import storm.trident.state.BaseQueryFunction;
+import storm.trident.tuple.TridentTuple;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class RedisStateSetCountQuerier extends BaseQueryFunction<RedisState, Long> {
+    private static final Logger logger = LoggerFactory.getLogger(RedisState.class);
+
+    private final String redisKeyPrefix;
+    private final TridentTupleMapper tupleMapper;
+
+    public RedisStateSetCountQuerier(String redisKeyPrefix, TridentTupleMapper tupleMapper) {
+        this.redisKeyPrefix = redisKeyPrefix;
+        this.tupleMapper = tupleMapper;
+    }
+
+    @Override
+    public List<Long> batchRetrieve(RedisState redisState, List<TridentTuple> inputs) {
+        List<Long> ret = new ArrayList<Long>();
+
+        JedisCommands jedisCommands = redisState.getInstance();
+        try {
+            for (TridentTuple input : inputs) {
+                String key = this.tupleMapper.getKeyFromTridentTuple(input);
+                if (redisKeyPrefix != null && redisKeyPrefix.length() > 0) {
+                    key = redisKeyPrefix + key;
+                }
+                long count = jedisCommands.scard(key);
+                ret.add(count);
+
+                logger.debug("redis get key[" + key + "] count[" + count + "]");
+            }
+        } finally {
+            redisState.returnInstance(jedisCommands);
+        }
+
+        return ret;
+    }
+
+    @Override
+    public void execute(TridentTuple tuple, Long s, TridentCollector collector) {
+        String key = this.tupleMapper.getKeyFromTridentTuple(tuple);
+        collector.emit(new Values(key, s));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/storm/blob/b2c07314/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java
new file mode 100644
index 0000000..742c9ac
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateSetUpdater.java
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident.state;
+
+import backtype.storm.tuple.Values;
+import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import redis.clients.jedis.JedisCommands;
+import storm.trident.operation.TridentCollector;
+import storm.trident.state.BaseStateUpdater;
+import storm.trident.tuple.TridentTuple;
+
+import java.util.List;
+
+public class RedisStateSetUpdater extends BaseStateUpdater<RedisState> {
+    private static final Logger logger = LoggerFactory.getLogger(RedisState.class);
+
+    private static final long DEFAULT_EXPIRE_INTERVAL_MS = 86400000;
+
+    private final String redisKeyPrefix;
+    private final TridentTupleMapper tupleMapper;
+    private final long expireIntervalMs;
+
+    public RedisStateSetUpdater(String redisKeyPrefix, TridentTupleMapper tupleMapper, long expireIntervalMs) {
+        this.redisKeyPrefix = redisKeyPrefix;
+        this.tupleMapper = tupleMapper;
+        if (expireIntervalMs > 0) {
+            this.expireIntervalMs = expireIntervalMs;
+        } else {
+            this.expireIntervalMs = DEFAULT_EXPIRE_INTERVAL_MS;
+        }
+    }
+
+    @Override
+    public void updateState(RedisState redisState, List<TridentTuple> inputs,
+                            TridentCollector collector) {
+        long expireAt = System.currentTimeMillis() + expireIntervalMs;
+
+        JedisCommands jedisCommands = redisState.getInstance();
+        try {
+            for (TridentTuple input : inputs) {
+                String key = this.tupleMapper.getKeyFromTridentTuple(input);
+                String redisKey = key;
+                if (redisKeyPrefix != null && redisKeyPrefix.length() > 0) {
+                    redisKey = redisKeyPrefix + redisKey;
+                }
+                String value = this.tupleMapper.getValueFromTridentTuple(input);
+
+                logger.debug("update key[" + key + "] redisKey[" + redisKey + "] value[" + value + "]");
+
+                jedisCommands.sadd(redisKey, value);
+                jedisCommands.expireAt(redisKey, expireAt);
+                Long count = jedisCommands.scard(redisKey);
+
+                collector.emit(new Values(key, count));
+            }
+        } finally {
+            redisState.returnInstance(jedisCommands);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/b2c07314/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java
new file mode 100644
index 0000000..3a4d42b
--- /dev/null
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisStateUpdater.java
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.redis.trident.state;
+
+import org.apache.storm.redis.trident.mapper.TridentTupleMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import redis.clients.jedis.JedisCommands;
+import storm.trident.operation.TridentCollector;
+import storm.trident.state.BaseStateUpdater;
+import storm.trident.tuple.TridentTuple;
+
+import java.util.List;
+
+public class RedisStateUpdater extends BaseStateUpdater<RedisState> {
+    private static final Logger logger = LoggerFactory.getLogger(RedisState.class);
+
+    private static final long DEFAULT_EXPIRE_INTERVAL_MS = 86400000;
+
+    private final String redisKeyPrefix;
+    private final TridentTupleMapper tupleMapper;
+    private final long expireIntervalMs;
+
+    public RedisStateUpdater(String redisKeyPrefix, TridentTupleMapper tupleMapper, long expireIntervalMs) {
+        this.redisKeyPrefix = redisKeyPrefix;
+        this.tupleMapper = tupleMapper;
+        if (expireIntervalMs > 0) {
+            this.expireIntervalMs = expireIntervalMs;
+        } else {
+            this.expireIntervalMs = DEFAULT_EXPIRE_INTERVAL_MS;
+        }
+    }
+
+    @Override
+    public void updateState(RedisState redisState, List<TridentTuple> inputs,
+                            TridentCollector collector) {
+        long expireAt = System.currentTimeMillis() + expireIntervalMs;
+
+        JedisCommands jedisCommands = redisState.getInstance();
+        try {
+            for (TridentTuple input : inputs) {
+                String key = this.tupleMapper.getKeyFromTridentTuple(input);
+                String redisKey = key;
+                if (redisKeyPrefix != null && redisKeyPrefix.length() > 0) {
+                    redisKey = redisKeyPrefix + redisKey;
+                }
+                String value = this.tupleMapper.getValueFromTridentTuple(input);
+
+                logger.debug("update key[" + key + "] redisKey[" + redisKey + "] value[" + value + "]");
+
+                jedisCommands.set(redisKey, value);
+                jedisCommands.expireAt(redisKey, expireAt);
+            }
+        } finally {
+            redisState.returnInstance(jedisCommands);
+        }
+    }
+}


[17/23] storm git commit: Remove comments which are not valid

Posted by bo...@apache.org.
Remove comments which are not valid


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

Branch: refs/heads/master
Commit: cc784591df8eafea6e6f4ef124e9abc93b31e82c
Parents: 3cee80f
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Wed Jan 21 08:26:06 2015 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Wed Jan 21 08:26:06 2015 +0900

----------------------------------------------------------------------
 external/storm-redis/README.md                  |  2 -
 external/storm-redis/pom.xml                    | 43 --------------------
 .../trident/state/RedisClusterMapState.java     |  1 -
 .../redis/trident/state/RedisClusterState.java  |  1 -
 .../redis/trident/state/RedisMapState.java      |  1 -
 .../storm/redis/trident/state/RedisState.java   |  1 -
 .../JedisCommandsContainerBuilder.java          |  1 -
 7 files changed, 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/cc784591/external/storm-redis/README.md
----------------------------------------------------------------------
diff --git a/external/storm-redis/README.md b/external/storm-redis/README.md
index 06f3940..17f74db 100644
--- a/external/storm-redis/README.md
+++ b/external/storm-redis/README.md
@@ -75,8 +75,6 @@ use it as a maven dependency:
 
 2. RedisClusterState and RedisClusterMapState, which provide JedisCluster interface, just for redis cluster.
 
-3. ShardedRedisState and ShardedRedisMapState, which provide ShardedJedis interface, but not implements now.
-
 RedisState
 ```java
         JedisPoolConfig poolConfig = new JedisPoolConfig.Builder()

http://git-wip-us.apache.org/repos/asf/storm/blob/cc784591/external/storm-redis/pom.xml
----------------------------------------------------------------------
diff --git a/external/storm-redis/pom.xml b/external/storm-redis/pom.xml
index cbe63ea..e4d7daa 100644
--- a/external/storm-redis/pom.xml
+++ b/external/storm-redis/pom.xml
@@ -62,47 +62,4 @@
             <version>18.0</version>
         </dependency>
     </dependencies>
-
-    <!--
-    <build>
-        <sourceDirectory>src</sourceDirectory>
-        <resources>
-            <resource>
-                <directory>${basedir}/multilang</directory>
-            </resource>
-            <resource>
-                <directory>${basedir}/resources</directory>
-            </resource>
-        </resources>
-
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-shade-plugin</artifactId>
-                <version>2.2</version>
-                <configuration>
-                    <artifactSet>
-                        <excludes>
-                            <exclude>junit:junit</exclude>
-                            <exclude>org.slf4j:slf4j-simple</exclude>
-                            <exclude>org.slf4j:slf4j-log4j12</exclude>
-                            <exclude>org.apache.zookeeper</exclude>
-                        </excludes>
-                    </artifactSet>
-                </configuration>
-                <executions>
-                    <execution>
-                        <phase>package</phase>
-                        <goals>
-                            <goal>shade</goal>
-                        </goals>
-                        <configuration>
-                            <finalName>${project.artifactId}-${project.version}-with-dependencies</finalName>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-    -->
 </project>

http://git-wip-us.apache.org/repos/asf/storm/blob/cc784591/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 04e5723..24c1df1 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
@@ -153,7 +153,6 @@ public class RedisClusterMapState<T> implements IBackingMap<T> {
 
 
     protected static class Factory implements StateFactory {
-        // TODO : serialize redis.clients.jedis.JedisPoolConfig
         public static final redis.clients.jedis.JedisPoolConfig DEFAULT_POOL_CONFIG = new redis.clients.jedis.JedisPoolConfig();
 
         JedisClusterConfig jedisClusterConfig;

http://git-wip-us.apache.org/repos/asf/storm/blob/cc784591/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 8516bca..493ffdd 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
@@ -39,7 +39,6 @@ public class RedisClusterState implements State {
     }
 
     public static class Factory implements StateFactory {
-        // TODO : serialize redis.clients.jedis.JedisPoolConfig
         public static final redis.clients.jedis.JedisPoolConfig DEFAULT_POOL_CONFIG = new redis.clients.jedis.JedisPoolConfig();
 
         private JedisClusterConfig jedisClusterConfig;

http://git-wip-us.apache.org/repos/asf/storm/blob/cc784591/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
index 1a5cc7c..f934cea 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisMapState.java
@@ -151,7 +151,6 @@ public class RedisMapState<T> implements IBackingMap<T> {
     }
 
     protected static class Factory implements StateFactory {
-        // TODO : serialize redis.clients.jedis.JedisPoolConfig
         public static final redis.clients.jedis.JedisPoolConfig DEFAULT_POOL_CONFIG = new redis.clients.jedis.JedisPoolConfig();
 
         JedisPoolConfig jedisPoolConfig;

http://git-wip-us.apache.org/repos/asf/storm/blob/cc784591/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisState.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisState.java b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisState.java
index cc5933f..f2fd624 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisState.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/trident/state/RedisState.java
@@ -40,7 +40,6 @@ public class RedisState implements State {
     }
 
     public static class Factory implements StateFactory {
-        // TODO : serialize redis.clients.jedis.JedisPoolConfig
         public static final redis.clients.jedis.JedisPoolConfig DEFAULT_POOL_CONFIG = new redis.clients.jedis.JedisPoolConfig();
 
         private JedisPoolConfig jedisPoolConfig;

http://git-wip-us.apache.org/repos/asf/storm/blob/cc784591/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsContainerBuilder.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsContainerBuilder.java b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsContainerBuilder.java
index 34fb5b1..8d2dd38 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsContainerBuilder.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/util/container/JedisCommandsContainerBuilder.java
@@ -24,7 +24,6 @@ import redis.clients.jedis.JedisPool;
 
 public class JedisCommandsContainerBuilder {
 
-    // TODO : serialize redis.clients.jedis.JedisPoolConfig
     public static final redis.clients.jedis.JedisPoolConfig DEFAULT_POOL_CONFIG = new redis.clients.jedis.JedisPoolConfig();
 
     public static JedisCommandsInstanceContainer build(JedisPoolConfig config) {


[18/23] storm git commit: Merge pull request #4 from HeartSaVioR/storm_redis_remove_unused_comments

Posted by bo...@apache.org.
Merge pull request #4 from HeartSaVioR/storm_redis_remove_unused_comments

Remove comments which are not valid

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

Branch: refs/heads/master
Commit: 3356c8692d1538f35a49527acd06d98013755673
Parents: 3cee80f cc78459
Author: DashengJu <da...@gmail.com>
Authored: Wed Jan 21 10:34:22 2015 +0800
Committer: DashengJu <da...@gmail.com>
Committed: Wed Jan 21 10:34:22 2015 +0800

----------------------------------------------------------------------
 external/storm-redis/README.md                  |  2 -
 external/storm-redis/pom.xml                    | 43 --------------------
 .../trident/state/RedisClusterMapState.java     |  1 -
 .../redis/trident/state/RedisClusterState.java  |  1 -
 .../redis/trident/state/RedisMapState.java      |  1 -
 .../storm/redis/trident/state/RedisState.java   |  1 -
 .../JedisCommandsContainerBuilder.java          |  1 -
 7 files changed, 50 deletions(-)
----------------------------------------------------------------------



[10/23] storm git commit: Bump up Jedis version to 2.6.2

Posted by bo...@apache.org.
Bump up Jedis version to 2.6.2


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

Branch: refs/heads/master
Commit: 00e1bad9fa2d517c9a7ee7a544900e39fea31f75
Parents: ff36ac8
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Thu Jan 1 12:26:03 2015 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jan 1 12:26:03 2015 +0900

----------------------------------------------------------------------
 external/storm-redis/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/00e1bad9/external/storm-redis/pom.xml
----------------------------------------------------------------------
diff --git a/external/storm-redis/pom.xml b/external/storm-redis/pom.xml
index 6213ae1..cbe63ea 100644
--- a/external/storm-redis/pom.xml
+++ b/external/storm-redis/pom.xml
@@ -41,7 +41,7 @@
     </developers>
 
     <properties>
-        <jedis.version>2.6.1</jedis.version>
+        <jedis.version>2.6.2</jedis.version>
     </properties>
 
     <dependencies>


[06/23] storm git commit: Merge pull request #2 from HeartSaVioR/branch_storm_redis

Posted by bo...@apache.org.
Merge pull request #2 from HeartSaVioR/branch_storm_redis

storm-redis : Introduce Basic Redis Bolt with some test topologies

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

Branch: refs/heads/master
Commit: 980dccee35066f676e58684ccdf2db8424aee611
Parents: ac9719b 171a8bf
Author: DashengJu <da...@gmail.com>
Authored: Tue Dec 30 17:54:50 2014 +0800
Committer: DashengJu <da...@gmail.com>
Committed: Tue Dec 30 17:54:50 2014 +0800

----------------------------------------------------------------------
 .../storm/redis/bolt/AbstractRedisBolt.java     |  50 +++++++
 .../redis/util/config/JedisClusterConfig.java   |  59 +++++++++
 .../redis/util/config/JedisPoolConfig.java      |  80 +++++++++++
 .../util/container/JedisClusterContainer.java   |  30 +++++
 .../JedisCommandsContainerBuilder.java          |  22 ++++
 .../JedisCommandsInstanceContainer.java         |   8 ++
 .../redis/util/container/JedisContainer.java    |  44 +++++++
 .../storm/redis/topology/LookupWordCount.java   | 131 +++++++++++++++++++
 .../redis/topology/PersistentWordCount.java     | 117 +++++++++++++++++
 .../storm/redis/topology/WordCounter.java       |  58 ++++++++
 .../apache/storm/redis/topology/WordSpout.java  |  88 +++++++++++++
 11 files changed, 687 insertions(+)
----------------------------------------------------------------------