Search in sources :

Example 1 with RedisLookupBolt

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());
}
Also used : RedisLookupBolt(org.apache.storm.redis.bolt.RedisLookupBolt) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) Config(org.apache.storm.Config) JedisPoolConfig(org.apache.storm.redis.common.config.JedisPoolConfig) JedisPoolConfig(org.apache.storm.redis.common.config.JedisPoolConfig) RedisLookupMapper(org.apache.storm.redis.common.mapper.RedisLookupMapper)

Aggregations

Config (org.apache.storm.Config)1 RedisLookupBolt (org.apache.storm.redis.bolt.RedisLookupBolt)1 JedisPoolConfig (org.apache.storm.redis.common.config.JedisPoolConfig)1 RedisLookupMapper (org.apache.storm.redis.common.mapper.RedisLookupMapper)1 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)1