Search in sources :

Example 1 with FileReadSpout

use of org.apache.storm.perf.spout.FileReadSpout in project storm by apache.

the class FileReadWordCountTopo method getTopology.

public static StormTopology getTopology(Map config) {
    final int spoutNum = Helper.getInt(config, SPOUT_NUM, DEFAULT_SPOUT_NUM);
    final int spBoltNum = Helper.getInt(config, SPLIT_NUM, DEFAULT_SPLIT_BOLT_NUM);
    final int cntBoltNum = Helper.getInt(config, COUNT_NUM, DEFAULT_COUNT_BOLT_NUM);
    final String inputFile = Helper.getStr(config, INPUT_FILE);
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout(SPOUT_ID, new FileReadSpout(inputFile), spoutNum);
    builder.setBolt(SPLIT_ID, new SplitSentenceBolt(), spBoltNum).localOrShuffleGrouping(SPOUT_ID);
    builder.setBolt(COUNT_ID, new CountBolt(), cntBoltNum).fieldsGrouping(SPLIT_ID, new Fields(SplitSentenceBolt.FIELDS));
    return builder.createTopology();
}
Also used : FileReadSpout(org.apache.storm.perf.spout.FileReadSpout) SplitSentenceBolt(org.apache.storm.perf.bolt.SplitSentenceBolt) Fields(org.apache.storm.tuple.Fields) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) CountBolt(org.apache.storm.perf.bolt.CountBolt)

Aggregations

CountBolt (org.apache.storm.perf.bolt.CountBolt)1 SplitSentenceBolt (org.apache.storm.perf.bolt.SplitSentenceBolt)1 FileReadSpout (org.apache.storm.perf.spout.FileReadSpout)1 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)1 Fields (org.apache.storm.tuple.Fields)1