Search in sources :

Example 1 with RandomIntegerSpout

use of org.apache.heron.examples.api.spout.RandomIntegerSpout in project heron by twitter.

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(org.apache.heron.api.topology.TopologyBuilder) Config(org.apache.heron.api.Config) RandomIntegerSpout(org.apache.heron.examples.api.spout.RandomIntegerSpout) SlidingWindowSumBolt(org.apache.heron.examples.api.bolt.SlidingWindowSumBolt) PrinterBolt(org.apache.heron.examples.api.bolt.PrinterBolt)

Aggregations

Config (org.apache.heron.api.Config)1 TopologyBuilder (org.apache.heron.api.topology.TopologyBuilder)1 PrinterBolt (org.apache.heron.examples.api.bolt.PrinterBolt)1 SlidingWindowSumBolt (org.apache.heron.examples.api.bolt.SlidingWindowSumBolt)1 RandomIntegerSpout (org.apache.heron.examples.api.spout.RandomIntegerSpout)1