You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by xi...@apache.org on 2017/04/13 01:04:25 UTC
[1/2] storm git commit: [STORM-2465] modify storm-redis's READEME.md
and update storm-redis.md
Repository: storm
Updated Branches:
refs/heads/master abcd97209 -> 91fb8f567
[STORM-2465] modify storm-redis's READEME.md and update storm-redis.md
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/219ffb84
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/219ffb84
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/219ffb84
Branch: refs/heads/master
Commit: 219ffb84bc15914a3e140f0928df2c184b175ea3
Parents: 65c8b7b
Author: liuzhaokun <li...@zte.com.cn>
Authored: Tue Apr 11 19:46:01 2017 +0800
Committer: \u5218\u5146\u576410206665 <li...@zte.com.cn>
Committed: Tue Apr 11 19:46:01 2017 +0800
----------------------------------------------------------------------
docs/storm-redis.md | 57 +++++++++++++++++++++++++++++++++----
external/storm-redis/README.md | 2 +-
2 files changed, 53 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/219ffb84/docs/storm-redis.md
----------------------------------------------------------------------
diff --git a/docs/storm-redis.md b/docs/storm-redis.md
index 87541b9..e6cda2f 100644
--- a/docs/storm-redis.md
+++ b/docs/storm-redis.md
@@ -25,13 +25,16 @@ use it as a maven dependency:
### For normal Bolt
-Storm-redis provides basic Bolt implementations, ```RedisLookupBolt``` and ```RedisStoreBolt```.
+Storm-redis provides basic Bolt implementations, ```RedisLookupBolt``` and ```RedisStoreBolt```, and ```RedisFilterBolt```.
-As name represents its usage, ```RedisLookupBolt``` retrieves value from Redis using key, and ```RedisStoreBolt``` stores key / value to Redis. One tuple will be matched to one key / value pair, and you can define match pattern to ```TupleMapper```.
+As name represents its usage, ```RedisLookupBolt``` retrieves value from Redis using key, and ```RedisStoreBolt``` stores key / value to Redis, and ```RedisFilterBolt``` filters out tuple which key or field doesn't exist on Redis.
-You can also choose data type from ```RedisDataTypeDescription``` to use. Please refer ```RedisDataTypeDescription.RedisDataType``` to see what data types are supported. In some data types (hash and sorted set), it requires additional key and converted key from tuple becomes element.
+One tuple will be matched to one key / value pair, and you can define match pattern to ```TupleMapper```.
-These interfaces are combined with ```RedisLookupMapper``` and ```RedisStoreMapper``` which fit ```RedisLookupBolt``` and ```RedisStoreBolt``` respectively.
+You can also choose data type from ```RedisDataTypeDescription``` to use. Please refer ```RedisDataTypeDescription.RedisDataType``` to see what data types are supported. In some data types (hash and sorted set, and set if only RedisFilterBolt), it requires additional key and converted key from tuple becomes element.
+
+These interfaces are combined with ```RedisLookupMapper``` and ```RedisStoreMapper``` and ```RedisFilterMapper``` which fit ```RedisLookupBolt``` and ```RedisStoreBolt```, and ```RedisFilterBolt``` respectively.
+(When you want to implement RedisFilterMapper, be sure to set declareOutputFields() to declare same fields to input stream, since FilterBolt forwards input tuples when they exist on Redis.)
#### RedisLookupBolt example
@@ -85,6 +88,50 @@ RedisLookupMapper lookupMapper = new WordCountRedisLookupMapper();
RedisLookupBolt lookupBolt = new RedisLookupBolt(poolConfig, lookupMapper);
```
+#### RedisFilterBolt example
+
+```java
+
+class BlacklistWordFilterMapper implements RedisFilterMapper {
+ private RedisDataTypeDescription description;
+ private final String setKey = "blacklist";
+
+ public BlacklistWordFilterMapper() {
+ description = new RedisDataTypeDescription(
+ RedisDataTypeDescription.RedisDataType.SET, setKey);
+ }
+
+ @Override
+ public void declareOutputFields(OutputFieldsDeclarer declarer) {
+ declarer.declare(new Fields("word", "count"));
+ }
+
+ @Override
+ public RedisDataTypeDescription getDataTypeDescription() {
+ return description;
+ }
+
+ @Override
+ public String getKeyFromTuple(ITuple tuple) {
+ return tuple.getStringByField("word");
+ }
+
+ @Override
+ public String getValueFromTuple(ITuple tuple) {
+ return null;
+ }
+}
+
+```
+
+```java
+
+JedisPoolConfig poolConfig = new JedisPoolConfig.Builder()
+ .setHost(host).setPort(port).build();
+RedisFilterMapper filterMapper = new BlacklistWordFilterMapper();
+RedisFilterBolt filterBolt = new RedisFilterBolt(poolConfig, filterMapper);
+```
+
#### RedisStoreBolt example
```java
@@ -125,7 +172,7 @@ RedisStoreBolt storeBolt = new RedisStoreBolt(poolConfig, storeMapper);
### For non-simple Bolt
-If your scenario doesn't fit ```RedisStoreBolt``` and ```RedisLookupBolt```, storm-redis also provides ```AbstractRedisBolt``` to let you extend and apply your business logic.
+If your scenario doesn't fit ```RedisStoreBolt``` and ```RedisLookupBolt``` and ```RedisFilterBolt```, storm-redis also provides ```AbstractRedisBolt``` to let you extend and apply your business logic.
```java
http://git-wip-us.apache.org/repos/asf/storm/blob/219ffb84/external/storm-redis/README.md
----------------------------------------------------------------------
diff --git a/external/storm-redis/README.md b/external/storm-redis/README.md
index 2c6c950..251f90c 100644
--- a/external/storm-redis/README.md
+++ b/external/storm-redis/README.md
@@ -14,7 +14,7 @@ use it as a maven dependency:
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-redis</artifactId>
- <version>{storm.version}</version>
+ <version>${storm.version}</version>
<type>jar</type>
</dependency>
```
[2/2] storm git commit: Merge branch 'master_redis_doc' of
https://github.com/liu-zhaokun/storm
Posted by xi...@apache.org.
Merge branch 'master_redis_doc' of https://github.com/liu-zhaokun/storm
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/91fb8f56
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/91fb8f56
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/91fb8f56
Branch: refs/heads/master
Commit: 91fb8f567feb629f230df6d0694a9d990ea28cb0
Parents: abcd972 219ffb8
Author: vesense <be...@163.com>
Authored: Thu Apr 13 09:03:28 2017 +0800
Committer: vesense <be...@163.com>
Committed: Thu Apr 13 09:03:28 2017 +0800
----------------------------------------------------------------------
docs/storm-redis.md | 57 +++++++++++++++++++++++++++++++++----
external/storm-redis/README.md | 2 +-
2 files changed, 53 insertions(+), 6 deletions(-)
----------------------------------------------------------------------