use of org.apache.storm.redis.bolt.RedisLookupBolt in project storm by apache.
the class LookupWordCount method main.
public static void main(String[] args) throws Exception {
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();
RedisLookupMapper lookupMapper = setupLookupMapper();
RedisLookupBolt lookupBolt = new RedisLookupBolt(poolConfig, lookupMapper);
PrintWordTotalCountBolt printBolt = new PrintWordTotalCountBolt();
// wordspout -> lookupbolt
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout(WORD_SPOUT, spout, 1);
builder.setBolt(LOOKUP_BOLT, lookupBolt, 1).shuffleGrouping(WORD_SPOUT);
builder.setBolt(PRINT_BOLT, printBolt, 1).shuffleGrouping(LOOKUP_BOLT);
String topoName = "test";
if (args.length == 3) {
topoName = args[2];
} else if (args.length > 3) {
System.out.println("Usage: LookupWordCount <redis host> <redis port> (topology name)");
return;
}
Config config = new Config();
StormSubmitter.submitTopology(topoName, config, builder.createTopology());
}
Aggregations