use of org.apache.storm.topology.base.BaseWindowedBolt in project storm by apache.
the class SlidingTupleTsTopology method main.
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
BaseWindowedBolt bolt = new SlidingWindowSumBolt().withWindow(new Duration(5, TimeUnit.SECONDS), new Duration(3, TimeUnit.SECONDS)).withTimestampField("ts").withLag(new Duration(5, TimeUnit.SECONDS));
builder.setSpout("integer", new RandomIntegerSpout(), 1);
builder.setBolt("slidingsum", bolt, 1).shuffleGrouping("integer");
builder.setBolt("printer", new PrinterBolt(), 1).shuffleGrouping("slidingsum");
Config conf = new Config();
conf.setDebug(true);
String topoName = "test";
if (args != null && args.length > 0) {
topoName = args[0];
}
conf.setNumWorkers(1);
StormSubmitter.submitTopologyWithProgressBar(topoName, conf, builder.createTopology());
}
use of org.apache.storm.topology.base.BaseWindowedBolt in project streamline by hortonworks.
the class WindowedQueryBolt_TestTopology method main.
public static void main(String[] args) throws Exception {
SquaresSpout squares = new SquaresSpout();
CubesSpout cubes = new CubesSpout();
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("squares", squares, 1);
builder.setSpout("cubes", cubes, 1);
BaseWindowedBolt joiner = new WindowedQueryBolt("cubes", "number").leftJoin("squares", "number", "cubes").select("number,square,cube").withTumblingWindow(BaseWindowedBolt.Count.of(1000));
builder.setBolt("joiner", joiner, 2).fieldsGrouping("squares", new Fields("number")).fieldsGrouping("cubes", new Fields("number"));
builder.setBolt("fileWrite", new FileWriteBolt(), 1).shuffleGrouping("joiner");
// - submit topo
// LocalCluster cluster = runOnLocalCluster(TOPO_NAME, builder.createTopology() );
// Thread.sleep(10 * 60*1000);
// System.err.println("Shutting down");
// cluster.killTopology(TOPO_NAME);
// cluster.shutdown();
}
Aggregations