Search in sources :

Example 1 with BaseWindowedBolt

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());
}
Also used : TopologyBuilder(org.apache.storm.topology.TopologyBuilder) Config(org.apache.storm.Config) RandomIntegerSpout(org.apache.storm.starter.spout.RandomIntegerSpout) Duration(org.apache.storm.topology.base.BaseWindowedBolt.Duration) SlidingWindowSumBolt(org.apache.storm.starter.bolt.SlidingWindowSumBolt) PrinterBolt(org.apache.storm.starter.bolt.PrinterBolt) BaseWindowedBolt(org.apache.storm.topology.base.BaseWindowedBolt)

Example 2 with BaseWindowedBolt

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();
}
Also used : Fields(org.apache.storm.tuple.Fields) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) BaseWindowedBolt(org.apache.storm.topology.base.BaseWindowedBolt)

Aggregations

TopologyBuilder (org.apache.storm.topology.TopologyBuilder)2 BaseWindowedBolt (org.apache.storm.topology.base.BaseWindowedBolt)2 Config (org.apache.storm.Config)1 PrinterBolt (org.apache.storm.starter.bolt.PrinterBolt)1 SlidingWindowSumBolt (org.apache.storm.starter.bolt.SlidingWindowSumBolt)1 RandomIntegerSpout (org.apache.storm.starter.spout.RandomIntegerSpout)1 Duration (org.apache.storm.topology.base.BaseWindowedBolt.Duration)1 Fields (org.apache.storm.tuple.Fields)1