use of com.twitter.heron.examples.api.spout.TestWordSpout in project incubator-heron by apache.
the class CustomGroupingTopology method main.
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("word", new TestWordSpout(), 2);
builder.setBolt("mybolt", new MyBolt(), 2).customGrouping("word", new MyCustomStreamGrouping());
Config conf = new Config();
// component resource configuration
conf.setComponentRam("word", ByteAmount.fromMegabytes(512));
conf.setComponentRam("mybolt", ByteAmount.fromMegabytes(512));
// container resource configuration
conf.setContainerDiskRequested(ByteAmount.fromGigabytes(2));
conf.setContainerRamRequested(ByteAmount.fromGigabytes(2));
conf.setContainerCpuRequested(2);
conf.setNumStmgrs(2);
HeronSubmitter.submitTopology(args[0], conf, builder.createTopology());
}
use of com.twitter.heron.examples.api.spout.TestWordSpout in project incubator-heron by apache.
the class ExclamationTopology method main.
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
int parallelism = 2;
int spouts = parallelism;
builder.setSpout("word", new TestWordSpout(Duration.ofMillis(0)), spouts);
int bolts = 2 * parallelism;
builder.setBolt("exclaim1", new ExclamationBolt(), bolts).shuffleGrouping("word");
Config conf = new Config();
conf.setDebug(true);
conf.setMaxSpoutPending(10);
conf.setMessageTimeoutSecs(600);
conf.put(Config.TOPOLOGY_WORKER_CHILDOPTS, "-XX:+HeapDumpOnOutOfMemoryError");
// resources configuration
conf.setComponentRam("word", ExampleResources.getComponentRam());
conf.setComponentRam("exclaim1", ExampleResources.getComponentRam());
conf.setContainerDiskRequested(ExampleResources.getContainerDisk(spouts + bolts, parallelism));
conf.setContainerRamRequested(ExampleResources.getContainerRam(spouts + bolts, parallelism));
conf.setContainerCpuRequested(1);
if (args != null && args.length > 0) {
conf.setNumStmgrs(parallelism);
HeronSubmitter.submitTopology(args[0], conf, builder.createTopology());
} else {
System.out.println("Topology name not provided as an argument, running in simulator mode.");
Simulator simulator = new Simulator();
simulator.submitTopology("test", conf, builder.createTopology());
Utils.sleep(10000);
simulator.killTopology("test");
simulator.shutdown();
}
}
use of com.twitter.heron.examples.api.spout.TestWordSpout in project incubator-heron by apache.
the class MultiSpoutExclamationTopology method main.
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("word0", new TestWordSpout(), 2);
builder.setSpout("word1", new TestWordSpout(), 2);
builder.setSpout("word2", new TestWordSpout(), 2);
builder.setBolt("exclaim1", new ExclamationBolt(), 2).shuffleGrouping("word0").shuffleGrouping("word1").shuffleGrouping("word2");
Config conf = new Config();
conf.setDebug(true);
conf.setMaxSpoutPending(10);
conf.put(Config.TOPOLOGY_WORKER_CHILDOPTS, "-XX:+HeapDumpOnOutOfMemoryError");
// component resource configuration
conf.setComponentRam("word0", ExampleResources.getComponentRam());
conf.setComponentRam("word1", ExampleResources.getComponentRam());
conf.setComponentRam("word2", ExampleResources.getComponentRam());
conf.setComponentRam("exclaim1", ExampleResources.getComponentRam());
// container resource configuration
conf.setContainerDiskRequested(ByteAmount.fromGigabytes(3));
conf.setContainerRamRequested(ByteAmount.fromGigabytes(2));
conf.setContainerCpuRequested(1);
if (args != null && args.length > 0) {
conf.setNumStmgrs(3);
HeronSubmitter.submitTopology(args[0], conf, builder.createTopology());
} else {
Simulator simulator = new Simulator();
simulator.submitTopology("test", conf, builder.createTopology());
Utils.sleep(10000);
simulator.killTopology("test");
simulator.shutdown();
}
}
use of com.twitter.heron.examples.api.spout.TestWordSpout in project incubator-heron by apache.
the class ComponentJVMOptionsTopology method main.
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("word", new TestWordSpout(), 2);
builder.setBolt("exclaim1", new ExclamationBolt(), 2).shuffleGrouping("word").addConfiguration("test-config", // Sample adding component-specific config
"test-key");
Config conf = new Config();
conf.setDebug(true);
conf.setMaxSpoutPending(10);
// TOPOLOGY_WORKER_CHILDOPTS will be a global one
conf.put(Config.TOPOLOGY_WORKER_CHILDOPTS, "-XX:+HeapDumpOnOutOfMemoryError");
// For each component, both the global and if any the component one will be appended.
// And the component one will take precedence
conf.setComponentJvmOptions("word", "-XX:NewSize=300m");
conf.setComponentJvmOptions("exclaim1", "-XX:NewSize=300m");
// component resource configuration
conf.setComponentCpu("word", 0.5);
conf.setComponentRam("word", ByteAmount.fromMegabytes(512));
conf.setComponentDisk("word", ByteAmount.fromMegabytes(512));
conf.setComponentCpu("exclaim1", 0.5);
conf.setComponentRam("exclaim1", ByteAmount.fromMegabytes(512));
conf.setComponentDisk("exclaim1", ByteAmount.fromMegabytes(512));
// container resource configuration
conf.setContainerDiskRequested(ByteAmount.fromGigabytes(2));
conf.setContainerRamRequested(ByteAmount.fromGigabytes(2));
conf.setContainerCpuRequested(2);
// Specify the size of ram padding to per container.
// Notice, this config will be considered as a hint,
// and it's up to the packing algorithm to determine whether to apply this hint
conf.setContainerRamPadding(ByteAmount.fromGigabytes(2));
if (args != null && args.length > 0) {
conf.setNumStmgrs(2);
HeronSubmitter.submitTopology(args[0], conf, builder.createTopology());
} else {
Simulator simulator = new Simulator();
simulator.submitTopology("test", conf, builder.createTopology());
Utils.sleep(10000);
simulator.killTopology("test");
simulator.shutdown();
}
}
Aggregations