use of com.twitter.heron.api.Config in project incubator-heron by apache.
the class ConfigBuilderTest method testBuildConfig_IncorrectMBResourceFormat_ExceptionThrow.
@Test(expected = IllegalArgumentException.class)
public void testBuildConfig_IncorrectMBResourceFormat_ExceptionThrow() throws Exception {
Config config = null;
try {
EcoParser ecoParser = new EcoParser();
InputStream inputStream = new ByteArrayInputStream(INCORRECT_MB_FORMAT_YAML.getBytes());
FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
EcoTopologyDefinition ecoTopologyDefinition = ecoParser.parseFromInputStream(inputStream, mockPropsStream, false);
config = subject.buildConfig(ecoTopologyDefinition);
} finally {
assertNull(config);
}
}
use of com.twitter.heron.api.Config in project incubator-heron by apache.
the class AckingTopology method main.
public static void main(String[] args) throws Exception {
if (args.length != 1) {
throw new RuntimeException("Specify topology name");
}
TopologyBuilder builder = new TopologyBuilder();
int spouts = 2;
int bolts = 2;
builder.setSpout("word", new AckingTestWordSpout(), spouts);
builder.setBolt("exclaim1", new ExclamationBolt(), bolts).shuffleGrouping("word");
Config conf = new Config();
conf.setDebug(true);
// Specifies that all tuples will be automatically failed if not acked within 10 seconds
conf.setMessageTimeoutSecs(10);
// Put an arbitrarily large number here if you don't want to slow the topology down
conf.setMaxSpoutPending(1000 * 1000 * 1000);
// To enable at-least-once delivery semantics
conf.setTopologyReliabilityMode(Config.TopologyReliabilityMode.ATLEAST_ONCE);
// Extra JVM options
conf.put(Config.TOPOLOGY_WORKER_CHILDOPTS, "-XX:+HeapDumpOnOutOfMemoryError");
// Component resource configuration
conf.setComponentRam("word", ExampleResources.getComponentRam());
conf.setComponentRam("exclaim1", ExampleResources.getComponentRam());
// Container resource configuration
conf.setContainerDiskRequested(ExampleResources.getContainerDisk(spouts + bolts, 2));
conf.setContainerRamRequested(ExampleResources.getContainerRam(spouts + bolts, 2));
conf.setContainerCpuRequested(1);
// Set the number of workers or stream managers
conf.setNumStmgrs(2);
HeronSubmitter.submitTopology(args[0], conf, builder.createTopology());
}
use of com.twitter.heron.api.Config 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.api.Config 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.api.Config 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();
}
}
Aggregations