Search in sources :

Example 1 with SlidingWindowSumBolt

use of com.twitter.heron.examples.api.bolt.SlidingWindowSumBolt in project incubator-heron by apache.

the class SlidingWindowTopology method main.

public static void main(String[] args) throws Exception {
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("integer", new RandomIntegerSpout(), 1);
    builder.setBolt("slidingsum", new SlidingWindowSumBolt().withWindow(BaseWindowedBolt.Count.of(30), BaseWindowedBolt.Count.of(10)), 1).shuffleGrouping("integer");
    builder.setBolt("tumblingavg", new TumblingWindowAvgBolt().withTumblingWindow(BaseWindowedBolt.Count.of(3)), 1).shuffleGrouping("slidingsum");
    builder.setBolt("printer", new PrinterBolt(), 1).shuffleGrouping("tumblingavg");
    Config conf = new Config();
    conf.setDebug(true);
    String topoName = "test";
    conf.setComponentRam("integer", ByteAmount.fromGigabytes(1));
    conf.setComponentRam("slidingsum", ByteAmount.fromGigabytes(1));
    conf.setComponentRam("tumblingavg", ByteAmount.fromGigabytes(1));
    conf.setComponentRam("printer", ByteAmount.fromGigabytes(1));
    conf.setContainerDiskRequested(ByteAmount.fromGigabytes(5));
    conf.setContainerCpuRequested(4);
    if (args != null && args.length > 0) {
        topoName = args[0];
    }
    HeronSubmitter.submitTopology(topoName, conf, builder.createTopology());
}
Also used : TopologyBuilder(com.twitter.heron.api.topology.TopologyBuilder) Config(com.twitter.heron.api.Config) RandomIntegerSpout(com.twitter.heron.examples.api.spout.RandomIntegerSpout) SlidingWindowSumBolt(com.twitter.heron.examples.api.bolt.SlidingWindowSumBolt) PrinterBolt(com.twitter.heron.examples.api.bolt.PrinterBolt)

Aggregations

Config (com.twitter.heron.api.Config)1 TopologyBuilder (com.twitter.heron.api.topology.TopologyBuilder)1 PrinterBolt (com.twitter.heron.examples.api.bolt.PrinterBolt)1 SlidingWindowSumBolt (com.twitter.heron.examples.api.bolt.SlidingWindowSumBolt)1 RandomIntegerSpout (com.twitter.heron.examples.api.spout.RandomIntegerSpout)1