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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations