Search in sources :

Example 1 with RollingCountAggBolt

use of org.apache.storm.starter.bolt.RollingCountAggBolt in project storm by apache.

the class SkewedRollingTopWords method run.

/**
 * Submits (runs) the topology.
 *
 * <p>Usage: "SkewedRollingTopWords [topology-name] [-local]"
 *
 * <p>By default, the topology is run locally under the name
 * "slidingWindowCounts".
 *
 * <p>Examples:
 *
 * <p>```
 * # Runs in remote/cluster mode, with topology name "production-topology"
 * $ storm jar storm-starter-jar-with-dependencies.jar org.apache.storm.starter.SkewedRollingTopWords production-topology ```
 *
 * @param args
 *          First positional argument (optional) is topology name, second
 *          positional argument (optional) defines whether to run the topology
 *          locally ("-local") or remotely, i.e. on a real cluster
 */
@Override
protected int run(String[] args) {
    String topologyName = "slidingWindowCounts";
    if (args.length >= 1) {
        topologyName = args[0];
    }
    TopologyBuilder builder = new TopologyBuilder();
    String spoutId = "wordGenerator";
    String counterId = "counter";
    String aggId = "aggregator";
    builder.setSpout(spoutId, new TestWordSpout(), 5);
    builder.setBolt(counterId, new RollingCountBolt(9, 3), 4).partialKeyGrouping(spoutId, new Fields("word"));
    builder.setBolt(aggId, new RollingCountAggBolt(), 4).fieldsGrouping(counterId, new Fields("obj"));
    String intermediateRankerId = "intermediateRanker";
    builder.setBolt(intermediateRankerId, new IntermediateRankingsBolt(TOP_N), 4).fieldsGrouping(aggId, new Fields("obj"));
    String totalRankerId = "finalRanker";
    builder.setBolt(totalRankerId, new TotalRankingsBolt(TOP_N)).globalGrouping(intermediateRankerId);
    LOG.info("Topology name: " + topologyName);
    return submit(topologyName, conf, builder);
}
Also used : RollingCountBolt(org.apache.storm.starter.bolt.RollingCountBolt) IntermediateRankingsBolt(org.apache.storm.starter.bolt.IntermediateRankingsBolt) Fields(org.apache.storm.tuple.Fields) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) TotalRankingsBolt(org.apache.storm.starter.bolt.TotalRankingsBolt) TestWordSpout(org.apache.storm.testing.TestWordSpout) RollingCountAggBolt(org.apache.storm.starter.bolt.RollingCountAggBolt)

Example 2 with RollingCountAggBolt

use of org.apache.storm.starter.bolt.RollingCountAggBolt in project jstorm by alibaba.

the class SkewedRollingTopWords method wireTopology.

private void wireTopology() throws InterruptedException {
    String spoutId = "wordGenerator";
    String counterId = "counter";
    String aggId = "aggregator";
    String intermediateRankerId = "intermediateRanker";
    String totalRankerId = "finalRanker";
    builder.setSpout(spoutId, new TestWordSpout(), 5);
    builder.setBolt(counterId, new RollingCountBolt(9, 3), 4).partialKeyGrouping(spoutId, new Fields("word"));
    builder.setBolt(aggId, new RollingCountAggBolt(), 4).fieldsGrouping(counterId, new Fields("obj"));
    builder.setBolt(intermediateRankerId, new IntermediateRankingsBolt(TOP_N), 4).fieldsGrouping(aggId, new Fields("obj"));
    builder.setBolt(totalRankerId, new TotalRankingsBolt(TOP_N)).globalGrouping(intermediateRankerId);
}
Also used : RollingCountBolt(org.apache.storm.starter.bolt.RollingCountBolt) IntermediateRankingsBolt(org.apache.storm.starter.bolt.IntermediateRankingsBolt) Fields(backtype.storm.tuple.Fields) TotalRankingsBolt(org.apache.storm.starter.bolt.TotalRankingsBolt) TestWordSpout(backtype.storm.testing.TestWordSpout) RollingCountAggBolt(org.apache.storm.starter.bolt.RollingCountAggBolt)

Aggregations

IntermediateRankingsBolt (org.apache.storm.starter.bolt.IntermediateRankingsBolt)2 RollingCountAggBolt (org.apache.storm.starter.bolt.RollingCountAggBolt)2 RollingCountBolt (org.apache.storm.starter.bolt.RollingCountBolt)2 TotalRankingsBolt (org.apache.storm.starter.bolt.TotalRankingsBolt)2 TestWordSpout (backtype.storm.testing.TestWordSpout)1 Fields (backtype.storm.tuple.Fields)1 TestWordSpout (org.apache.storm.testing.TestWordSpout)1 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)1 Fields (org.apache.storm.tuple.Fields)1