diff --git a/examples/storm-redis-examples/pom.xml b/examples/storm-redis-examples/pom.xml index 1a8914fc58b..4ec2347bf89 100644 --- a/examples/storm-redis-examples/pom.xml +++ b/examples/storm-redis-examples/pom.xml @@ -91,7 +91,7 @@ maven-checkstyle-plugin - 54 + 0 diff --git a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/tools/Base64ToBinaryStateMigrationUtil.java b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/tools/Base64ToBinaryStateMigrationUtil.java index 68bf9ddf8a2..9f060b8067a 100644 --- a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/tools/Base64ToBinaryStateMigrationUtil.java +++ b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/tools/Base64ToBinaryStateMigrationUtil.java @@ -38,7 +38,6 @@ import redis.clients.util.SafeEncoder; - public class Base64ToBinaryStateMigrationUtil { private static final Logger LOG = LoggerFactory.getLogger(Base64ToBinaryStateMigrationUtil.class); private static final String OPTION_REDIS_HOST_SHORT = "h"; diff --git a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/LookupWordCount.java b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/LookupWordCount.java index 475bbab3bdf..54456eccf48 100644 --- a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/LookupWordCount.java +++ b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/LookupWordCount.java @@ -15,8 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.storm.redis.topology; +import com.google.common.collect.Lists; + import java.util.List; import java.util.Map; import java.util.Random; @@ -36,11 +39,10 @@ import org.apache.storm.tuple.ITuple; import org.apache.storm.tuple.Tuple; import org.apache.storm.tuple.Values; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.collect.Lists; - public class LookupWordCount { private static final String WORD_SPOUT = "WORD_SPOUT"; private static final String LOOKUP_BOLT = "LOOKUP_BOLT"; @@ -65,7 +67,7 @@ public void execute(Tuple input) { String countStr = input.getStringByField("count"); // print lookup result with low probability - if(RANDOM.nextInt(1000) > 995) { + if (RANDOM.nextInt(1000) > 995) { int count = 0; if (countStr != null) { count = Integer.parseInt(countStr); @@ -82,8 +84,6 @@ 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; @@ -114,6 +114,7 @@ public static void main(String[] args) throws Exception { System.out.println("Usage: LookupWordCount (topology name)"); return; } + Config config = new Config(); StormSubmitter.submitTopology(topoName, config, builder.createTopology()); } diff --git a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/PersistentWordCount.java b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/PersistentWordCount.java index 4c7b0dc3efb..eca75ea63e0 100644 --- a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/PersistentWordCount.java +++ b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/PersistentWordCount.java @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.storm.redis.topology; import org.apache.storm.Config; @@ -36,8 +37,6 @@ public class PersistentWordCount { private static final int TEST_REDIS_PORT = 6379; public static void main(String[] args) throws Exception { - Config config = new Config(); - String host = TEST_REDIS_HOST; int port = TEST_REDIS_PORT; @@ -68,6 +67,7 @@ public static void main(String[] args) throws Exception { System.out.println("Usage: PersistentWordCount (topology name)"); return; } + Config config = new Config(); StormSubmitter.submitTopology(topoName, config, builder.createTopology()); } diff --git a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/WhitelistWordCount.java b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/WhitelistWordCount.java index 9999afea0d0..8640335718c 100644 --- a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/WhitelistWordCount.java +++ b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/WhitelistWordCount.java @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.storm.redis.topology; import java.util.Map; @@ -62,7 +63,7 @@ public void execute(Tuple input) { String countStr = input.getStringByField("count"); // print lookup result with low probability - if(RANDOM.nextInt(1000) > 995) { + if (RANDOM.nextInt(1000) > 995) { int count = 0; if (countStr != null) { count = Integer.parseInt(countStr); @@ -79,8 +80,6 @@ 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; @@ -96,12 +95,12 @@ public static void main(String[] args) throws Exception { RedisFilterMapper filterMapper = setupWhitelistMapper(); RedisFilterBolt whitelistBolt = new RedisFilterBolt(poolConfig, filterMapper); WordCounter wordCounterBolt = new WordCounter(); - PrintWordTotalCountBolt printBolt = new PrintWordTotalCountBolt(); TopologyBuilder builder = new TopologyBuilder(); builder.setSpout(WORD_SPOUT, spout, 1); builder.setBolt(WHITELIST_BOLT, whitelistBolt, 1).shuffleGrouping(WORD_SPOUT); builder.setBolt(COUNT_BOLT, wordCounterBolt, 1).fieldsGrouping(WHITELIST_BOLT, new Fields("word")); + PrintWordTotalCountBolt printBolt = new PrintWordTotalCountBolt(); builder.setBolt(PRINT_BOLT, printBolt, 1).shuffleGrouping(COUNT_BOLT); String topoName = "test"; @@ -111,6 +110,7 @@ public static void main(String[] args) throws Exception { System.out.println("Usage: WhitelistWordCount [topology name]"); return; } + Config config = new Config(); StormSubmitter.submitTopology(topoName, config, builder.createTopology()); } diff --git a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/WordCounter.java b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/WordCounter.java index 8595d1ef16a..a0b9714c804 100644 --- a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/WordCounter.java +++ b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/WordCounter.java @@ -15,8 +15,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.storm.redis.topology; +import com.google.common.collect.Maps; + +import java.util.Map; + import org.apache.storm.task.TopologyContext; import org.apache.storm.topology.BasicOutputCollector; import org.apache.storm.topology.IBasicBolt; @@ -24,9 +29,6 @@ import org.apache.storm.tuple.Fields; import org.apache.storm.tuple.Tuple; import org.apache.storm.tuple.Values; -import com.google.common.collect.Maps; - -import java.util.Map; public class WordCounter implements IBasicBolt { private Map wordCounter = Maps.newHashMap(); diff --git a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/WordSpout.java b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/WordSpout.java index a3877625328..ff3ec39101b 100644 --- a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/WordSpout.java +++ b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/topology/WordSpout.java @@ -15,8 +15,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.storm.redis.topology; +import java.util.Map; +import java.util.Random; +import java.util.UUID; + import org.apache.storm.spout.SpoutOutputCollector; import org.apache.storm.task.TopologyContext; import org.apache.storm.topology.IRichSpout; @@ -24,10 +29,6 @@ import org.apache.storm.tuple.Fields; import org.apache.storm.tuple.Values; -import java.util.Map; -import java.util.Random; -import java.util.UUID; - public class WordSpout implements IRichSpout { boolean isDistributed; SpoutOutputCollector collector; diff --git a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/PrintFunction.java b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/PrintFunction.java index 37d393693b0..f32cfe8e037 100644 --- a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/PrintFunction.java +++ b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/PrintFunction.java @@ -15,15 +15,17 @@ * 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 java.util.Random; + import org.apache.storm.trident.operation.BaseFunction; import org.apache.storm.trident.operation.TridentCollector; import org.apache.storm.trident.tuple.TridentTuple; -import java.util.Random; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrintFunction extends BaseFunction { @@ -33,7 +35,7 @@ public class PrintFunction extends BaseFunction { @Override public void execute(TridentTuple tuple, TridentCollector tridentCollector) { - if(RANDOM.nextInt(1000) > 995) { + if (RANDOM.nextInt(1000) > 995) { LOG.info(tuple.toString()); } } diff --git a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountLookupMapper.java b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountLookupMapper.java index a6ca8c9c1de..04874d5f13c 100644 --- a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountLookupMapper.java +++ b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountLookupMapper.java @@ -15,17 +15,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.storm.redis.trident; +import java.util.ArrayList; +import java.util.List; + +import org.apache.storm.redis.common.mapper.RedisDataTypeDescription; +import org.apache.storm.redis.common.mapper.RedisLookupMapper; import org.apache.storm.topology.OutputFieldsDeclarer; import org.apache.storm.tuple.Fields; import org.apache.storm.tuple.ITuple; import org.apache.storm.tuple.Values; -import org.apache.storm.redis.common.mapper.RedisDataTypeDescription; -import org.apache.storm.redis.common.mapper.RedisLookupMapper; - -import java.util.ArrayList; -import java.util.List; public class WordCountLookupMapper implements RedisLookupMapper { @Override diff --git a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountStoreMapper.java b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountStoreMapper.java index 58df150c4b1..84538e232e4 100644 --- a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountStoreMapper.java +++ b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountStoreMapper.java @@ -15,11 +15,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.storm.redis.trident; -import org.apache.storm.tuple.ITuple; import org.apache.storm.redis.common.mapper.RedisDataTypeDescription; import org.apache.storm.redis.common.mapper.RedisStoreMapper; +import org.apache.storm.tuple.ITuple; public class WordCountStoreMapper implements RedisStoreMapper { @Override diff --git a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountTridentRedis.java b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountTridentRedis.java index c162ca6dce4..b5716350c8e 100644 --- a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountTridentRedis.java +++ b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountTridentRedis.java @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.storm.redis.trident; import org.apache.storm.Config; @@ -34,7 +35,8 @@ import org.apache.storm.tuple.Values; public class WordCountTridentRedis { - public static StormTopology buildTopology(String redisHost, Integer redisPort){ + + public static StormTopology buildTopology(String redisHost, Integer redisPort) { Fields fields = new Fields("word", "count"); FixedBatchSpout spout = new FixedBatchSpout(fields, 4, new Values("storm", 1), diff --git a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountTridentRedisCluster.java b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountTridentRedisCluster.java index 687ac541e6d..be515d8dc7a 100644 --- a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountTridentRedisCluster.java +++ b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountTridentRedisCluster.java @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.storm.redis.trident; import java.net.InetSocketAddress; @@ -38,7 +39,8 @@ import org.apache.storm.tuple.Values; public class WordCountTridentRedisCluster { - public static StormTopology buildTopology(String redisHostPort){ + + public static StormTopology buildTopology(String redisHostPort) { Fields fields = new Fields("word", "count"); FixedBatchSpout spout = new FixedBatchSpout(fields, 4, new Values("storm", 1), @@ -50,8 +52,8 @@ public static StormTopology buildTopology(String redisHostPort){ Set nodes = new HashSet(); for (String hostPort : redisHostPort.split(",")) { - String[] host_port = hostPort.split(":"); - nodes.add(new InetSocketAddress(host_port[0], Integer.valueOf(host_port[1]))); + String[] hostPortSplit = hostPort.split(":"); + nodes.add(new InetSocketAddress(hostPortSplit[0], Integer.valueOf(hostPortSplit[1]))); } JedisClusterConfig clusterConfig = new JedisClusterConfig.Builder().setNodes(nodes) .build(); diff --git a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountTridentRedisClusterMap.java b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountTridentRedisClusterMap.java index 8cf0f3cd7be..b1425c9bf34 100644 --- a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountTridentRedisClusterMap.java +++ b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountTridentRedisClusterMap.java @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.storm.redis.trident; import java.net.InetSocketAddress; @@ -38,7 +39,8 @@ import org.apache.storm.tuple.Values; public class WordCountTridentRedisClusterMap { - public static StormTopology buildTopology(String redisHostPort){ + + public static StormTopology buildTopology(String redisHostPort) { Fields fields = new Fields("word", "count"); FixedBatchSpout spout = new FixedBatchSpout(fields, 4, new Values("storm", 1), @@ -50,8 +52,8 @@ public static StormTopology buildTopology(String redisHostPort){ Set nodes = new HashSet(); for (String hostPort : redisHostPort.split(",")) { - String[] host_port = hostPort.split(":"); - nodes.add(new InetSocketAddress(host_port[0], Integer.valueOf(host_port[1]))); + String[] hostPortSplit = hostPort.split(":"); + nodes.add(new InetSocketAddress(hostPortSplit[0], Integer.valueOf(hostPortSplit[1]))); } JedisClusterConfig clusterConfig = new JedisClusterConfig.Builder().setNodes(nodes) .build(); diff --git a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountTridentRedisMap.java b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountTridentRedisMap.java index dac0a4d3fdb..2a7af97f3b8 100644 --- a/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountTridentRedisMap.java +++ b/examples/storm-redis-examples/src/main/java/org/apache/storm/redis/trident/WordCountTridentRedisMap.java @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.storm.redis.trident; import org.apache.storm.Config; @@ -34,7 +35,8 @@ import org.apache.storm.tuple.Values; public class WordCountTridentRedisMap { - public static StormTopology buildTopology(String redisHost, Integer redisPort){ + + public static StormTopology buildTopology(String redisHost, Integer redisPort) { Fields fields = new Fields("word", "count"); FixedBatchSpout spout = new FixedBatchSpout(fields, 4, new Values("storm", 1),