Search in sources :

Example 1 with PrinterBolt

use of org.apache.heron.examples.api.bolt.PrinterBolt in project heron by twitter.

the class StatefulSlidingWindowTopology method main.

public static void main(String[] args) throws Exception {
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("integer", new IntegerSpout(), 1);
    builder.setBolt("sumbolt", new WindowSumBolt().withWindow(BaseWindowedBolt.Count.of(5), BaseWindowedBolt.Count.of(3)), 1).shuffleGrouping("integer");
    builder.setBolt("printer", new PrinterBolt()).shuffleGrouping("sumbolt");
    Config conf = new Config();
    conf.setDebug(true);
    String topoName = "test";
    Config.setComponentRam(conf, "integer", ByteAmount.fromGigabytes(1));
    Config.setComponentRam(conf, "sumbolt", ByteAmount.fromGigabytes(1));
    Config.setComponentRam(conf, "printer", ByteAmount.fromGigabytes(1));
    Config.setContainerDiskRequested(conf, ByteAmount.fromGigabytes(5));
    Config.setContainerCpuRequested(conf, 4);
    conf.setTopologyReliabilityMode(Config.TopologyReliabilityMode.EFFECTIVELY_ONCE);
    conf.setTopologyStatefulCheckpointIntervalSecs(20);
    conf.setMaxSpoutPending(1000);
    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) PrinterBolt(org.apache.heron.examples.api.bolt.PrinterBolt)

Example 2 with PrinterBolt

use of org.apache.heron.examples.api.bolt.PrinterBolt 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)

Example 3 with PrinterBolt

use of org.apache.heron.examples.api.bolt.PrinterBolt in project heron by twitter.

the class StatefulTumblingWindowTopology method main.

public static void main(String[] args) throws Exception {
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("integer", new IntegerSpout(), 1);
    WindowSumBolt windowSumBolt = new WindowSumBolt();
    windowSumBolt.withTumblingWindow(Duration.ofMinutes(10));
    builder.setBolt("sumbolt", windowSumBolt, 1).shuffleGrouping("integer");
    builder.setBolt("printer", new PrinterBolt()).shuffleGrouping("sumbolt");
    Config conf = new Config();
    conf.setDebug(true);
    String topoName = "test";
    Config.setComponentRam(conf, "integer", ByteAmount.fromGigabytes(1));
    Config.setComponentRam(conf, "sumbolt", ByteAmount.fromGigabytes(1));
    Config.setComponentRam(conf, "printer", ByteAmount.fromGigabytes(1));
    Config.setContainerDiskRequested(conf, ByteAmount.fromGigabytes(5));
    Config.setContainerCpuRequested(conf, 4);
    conf.setTopologyReliabilityMode(Config.TopologyReliabilityMode.EFFECTIVELY_ONCE);
    conf.setTopologyStatefulCheckpointIntervalSecs(20);
    conf.setMaxSpoutPending(1000);
    conf.setMessageTimeoutSecs(1500);
    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) PrinterBolt(org.apache.heron.examples.api.bolt.PrinterBolt)

Aggregations

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