Search in sources :

Example 46 with Fields

use of com.twitter.heron.api.tuple.Fields in project incubator-heron by apache.

the class WordCountTopology method main.

/**
 * Main method
 */
public static void main(String[] args) throws AlreadyAliveException, InvalidTopologyException {
    if (args.length < 1) {
        throw new RuntimeException("Specify topology name");
    }
    int parallelism = 1;
    if (args.length > 1) {
        parallelism = Integer.parseInt(args[1]);
    }
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("word", new WordSpout(), parallelism);
    builder.setBolt("consumer", new ConsumerBolt(), parallelism).fieldsGrouping("word", new Fields("word"));
    Config conf = new Config();
    conf.setNumStmgrs(parallelism);
    // configure component resources
    conf.setComponentRam("word", ByteAmount.fromMegabytes(ExampleResources.COMPONENT_RAM_MB * 2));
    conf.setComponentRam("consumer", ByteAmount.fromMegabytes(ExampleResources.COMPONENT_RAM_MB * 2));
    // configure container resources
    conf.setContainerDiskRequested(ExampleResources.getContainerDisk(2 * parallelism, parallelism));
    conf.setContainerRamRequested(ExampleResources.getContainerRam(2 * parallelism, parallelism));
    conf.setContainerCpuRequested(2);
    HeronSubmitter.submitTopology(args[0], conf, builder.createTopology());
}
Also used : Fields(com.twitter.heron.api.tuple.Fields) TopologyBuilder(com.twitter.heron.api.topology.TopologyBuilder) Config(com.twitter.heron.api.Config)

Example 47 with Fields

use of com.twitter.heron.api.tuple.Fields in project incubator-heron by apache.

the class WindowedWordCountTopology method main.

public static void main(String[] args) throws AlreadyAliveException, InvalidTopologyException {
    int parallelism = 1;
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("sentence", new SentenceSpout(), parallelism);
    builder.setBolt("split", new SplitSentence(), parallelism).shuffleGrouping("sentence");
    builder.setBolt("consumer", new WindowSumBolt().withWindow(BaseWindowedBolt.Count.of(10000), BaseWindowedBolt.Count.of(5000)), parallelism).fieldsGrouping("split", new Fields("word"));
    Config conf = new Config();
    conf.setMaxSpoutPending(1000000);
    HeronSubmitter.submitTopology(args[0], conf, builder.createTopology());
}
Also used : Fields(com.twitter.heron.api.tuple.Fields) TopologyBuilder(com.twitter.heron.api.topology.TopologyBuilder) Config(com.twitter.heron.api.Config)

Example 48 with Fields

use of com.twitter.heron.api.tuple.Fields in project streaming-samples by ashvina.

the class AckingWordCount2StageTopology method main.

public static void main(String[] args) throws Exception {
    TopologyArgParser parser = new TopologyArgParser(args, SPOUT, COUNT);
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout(SPOUT, new AckingRandomWordSpout(), parser.get(SPOUT));
    builder.setBolt(COUNT, new WordCount(), parser.get(COUNT)).fieldsGrouping(SPOUT, new Fields(WordCountTopologyHelper.FIELD_WORD));
    Config conf = new Config();
    conf.setDebug(false);
    conf.setNumStmgrs(parser.getNumWorkers());
    conf.setEnableAcking(true);
    conf.setMaxSpoutPending(Integer.MAX_VALUE);
    HeronSubmitter.submitTopology(args[0], conf, builder.createTopology());
}
Also used : TopologyArgParser(com.github.ashvina.common.TopologyArgParser) Fields(com.twitter.heron.api.tuple.Fields) TopologyBuilder(com.twitter.heron.api.topology.TopologyBuilder) Config(com.twitter.heron.api.Config)

Example 49 with Fields

use of com.twitter.heron.api.tuple.Fields in project streaming-samples by ashvina.

the class AckingWordCountTopology method main.

public static void main(String[] args) throws Exception {
    TopologyArgParser parser = new TopologyArgParser(args, SPOUT, SPLIT, COUNT);
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout(SPOUT, new AckingStormRandomSentenceSpout(), parser.get(SPOUT));
    builder.setBolt(SPLIT, new SplitSentence(), parser.get(SPLIT)).shuffleGrouping(SPOUT);
    builder.setBolt(COUNT, new WordCount(), parser.get(COUNT)).fieldsGrouping(SPLIT, new Fields(WordCountTopologyHelper.FIELD_WORD));
    Config conf = new Config();
    conf.setDebug(false);
    conf.setNumStmgrs(parser.getNumWorkers());
    conf.setEnableAcking(true);
    conf.setMaxSpoutPending(Integer.MAX_VALUE);
    HeronSubmitter.submitTopology(args[0], conf, builder.createTopology());
}
Also used : TopologyArgParser(com.github.ashvina.common.TopologyArgParser) Fields(com.twitter.heron.api.tuple.Fields) TopologyBuilder(com.twitter.heron.api.topology.TopologyBuilder) Config(com.twitter.heron.api.Config)

Example 50 with Fields

use of com.twitter.heron.api.tuple.Fields in project streaming-samples by ashvina.

the class NoAckWordCountTopology method main.

public static void main(String[] args) throws Exception {
    TopologyArgParser parser = new TopologyArgParser(args, SPOUT, SPLIT, COUNT);
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout(SPOUT, new NoAckStormRandomSentenceSpout(), parser.get(SPOUT));
    builder.setBolt(SPLIT, new SplitSentence(), parser.get(SPLIT)).shuffleGrouping(SPOUT);
    builder.setBolt(COUNT, new WordCount(), parser.get(COUNT)).fieldsGrouping(SPLIT, new Fields(WordCountTopologyHelper.FIELD_WORD));
    Config conf = new Config();
    conf.setDebug(false);
    conf.setEnableAcking(false);
    conf.setNumStmgrs(parser.getNumWorkers());
    HeronSubmitter.submitTopology(args[0], conf, builder.createTopology());
}
Also used : TopologyArgParser(com.github.ashvina.common.TopologyArgParser) Fields(com.twitter.heron.api.tuple.Fields) TopologyBuilder(com.twitter.heron.api.topology.TopologyBuilder) Config(com.twitter.heron.api.Config)

Aggregations

Fields (com.twitter.heron.api.tuple.Fields)50 ABSpout (com.twitter.heron.integration_test.common.spout.ABSpout)22 IdentityBolt (com.twitter.heron.integration_test.common.bolt.IdentityBolt)20 Config (com.twitter.heron.api.Config)13 TopologyBuilder (com.twitter.heron.api.topology.TopologyBuilder)13 Tuple (com.twitter.heron.api.tuple.Tuple)8 TopologyArgParser (com.github.ashvina.common.TopologyArgParser)5 TopologyAPI (com.twitter.heron.api.generated.TopologyAPI)5 TopologyContext (com.twitter.heron.api.topology.TopologyContext)5 Values (com.twitter.heron.api.tuple.Values)5 HashMap (java.util.HashMap)5 BaseBasicBolt (com.twitter.heron.api.bolt.BaseBasicBolt)4 BasicOutputCollector (com.twitter.heron.api.bolt.BasicOutputCollector)4 BaseRichSpout (com.twitter.heron.api.spout.BaseRichSpout)4 SpoutOutputCollector (com.twitter.heron.api.spout.SpoutOutputCollector)4 OutputFieldsDeclarer (com.twitter.heron.api.topology.OutputFieldsDeclarer)4 TupleWindow (com.twitter.heron.api.windowing.TupleWindow)4 Map (java.util.Map)4 TupleWindowImpl (com.twitter.heron.api.windowing.TupleWindowImpl)3 ArrayList (java.util.ArrayList)3