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);
}
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);
}
Aggregations