use of com.twitter.heron.simulator.Simulator 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.simulator.Simulator in project incubator-heron by apache.
the class MultiStageAckingTopology method main.
public static void main(String[] args) throws Exception {
if (args.length != 1) {
throw new RuntimeException("Please specify the name of the topology");
}
TopologyBuilder builder = new TopologyBuilder();
int parallelism = 2;
builder.setSpout("word", new AckingTestWordSpout(), parallelism);
builder.setBolt("exclaim1", new ExclamationBolt(true), parallelism).shuffleGrouping("word");
builder.setBolt("exclaim2", new ExclamationBolt(false), parallelism).shuffleGrouping("exclaim1");
Config conf = new Config();
conf.setDebug(true);
// Put an arbitrary large number here if you don't want to slow the topology down
conf.setMaxSpoutPending(1000 * 1000 * 1000);
// To enable acking, we need to setEnableAcking true
conf.setTopologyReliabilityMode(Config.TopologyReliabilityMode.ATLEAST_ONCE);
conf.put(Config.TOPOLOGY_WORKER_CHILDOPTS, "-XX:+HeapDumpOnOutOfMemoryError");
// component resource configuration
conf.setComponentRam("word", ExampleResources.getComponentRam());
conf.setComponentRam("exclaim1", ExampleResources.getComponentRam());
conf.setComponentRam("exclaim2", ExampleResources.getComponentRam());
// container resource configuration
conf.setContainerDiskRequested(ExampleResources.getContainerDisk(3 * parallelism, parallelism));
conf.setContainerRamRequested(ExampleResources.getContainerRam(3 * parallelism, parallelism));
conf.setContainerCpuRequested(1);
if (args != null && args.length > 0) {
conf.setNumStmgrs(parallelism);
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.simulator.Simulator 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.simulator.Simulator 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