Search in sources :

Example 26 with Config

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

the class Eco method submit.

public void submit(FileInputStream fileInputStream, FileInputStream propertiesFile, boolean envFilter) throws Exception {
    EcoTopologyDefinition topologyDefinition = ecoParser.parseFromInputStream(fileInputStream, propertiesFile, envFilter);
    String topologyName = topologyDefinition.getName();
    Config topologyConfig = ecoBuilder.buildConfig(topologyDefinition);
    EcoExecutionContext executionContext = new EcoExecutionContext(topologyDefinition, topologyConfig);
    printTopologyInfo(executionContext);
    ObjectBuilder objectBuilder = new ObjectBuilder();
    objectBuilder.setBuilderUtility(new BuilderUtility());
    TopologyBuilder builder = ecoBuilder.buildTopologyBuilder(executionContext, objectBuilder);
    ecoSubmitter.submitTopology(topologyName, topologyConfig, builder.createTopology());
}
Also used : TopologyBuilder(org.apache.storm.topology.TopologyBuilder) Config(com.twitter.heron.api.Config) EcoExecutionContext(com.twitter.heron.eco.definition.EcoExecutionContext) EcoTopologyDefinition(com.twitter.heron.eco.definition.EcoTopologyDefinition) ObjectBuilder(com.twitter.heron.eco.builder.ObjectBuilder) BuilderUtility(com.twitter.heron.eco.builder.BuilderUtility)

Example 27 with Config

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

the class ConfigBuilder method buildConfig.

protected Config buildConfig(EcoTopologyDefinition topologyDefinition) throws IllegalArgumentException {
    Map<String, Object> configMap = topologyDefinition.getConfig();
    Config config = new Config();
    for (Map.Entry<String, Object> entry : configMap.entrySet()) {
        if (entry.getKey().equals(COMPONENT_RESOURCE_MAP)) {
            setComponentLevelResource(config, entry);
        } else if (entry.getKey().equals(COMPONENT_JVM_OPTIONS)) {
            List<Object> objects = (List<Object>) entry.getValue();
            for (Object obj : objects) {
                String objString = obj.toString();
                objString = objString.replace(LEFT_BRACE, WHITESPACE);
                objString = objString.replace(RIGHT_BRACE, WHITESPACE);
                int idIndex = objString.indexOf(ID);
                int optionsIndex = objString.indexOf(OPTIONS);
                String id = getIdValue(objString, idIndex);
                String jvmOptions;
                if (optionsIndex != -1) {
                    int equalsIndex = objString.indexOf(EQUALS, optionsIndex);
                    jvmOptions = objString.substring(equalsIndex + 1, objString.length());
                    jvmOptions = jvmOptions.replace(LEFT_BRACKET, "").replace(RIGHT_BRACKET, "");
                } else {
                    throw new IllegalArgumentException("You must specify the JVM options for your component");
                }
                config.setComponentJvmOptions(id, jvmOptions);
            }
        } else {
            config.put(entry.getKey(), entry.getValue());
        }
    }
    return config;
}
Also used : Config(com.twitter.heron.api.Config) List(java.util.List) Map(java.util.Map)

Example 28 with Config

use of com.twitter.heron.api.Config 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();
    }
}
Also used : TopologyBuilder(com.twitter.heron.api.topology.TopologyBuilder) Config(com.twitter.heron.api.Config) TestWordSpout(com.twitter.heron.examples.api.spout.TestWordSpout) Simulator(com.twitter.heron.simulator.Simulator)

Example 29 with Config

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

the class SentenceWordCountTopology method main.

public static void main(String[] args) throws Exception {
    String name = "fast-word-count-topology";
    if (args != null && args.length > 0) {
        name = args[0];
    }
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("spout", new FastRandomSentenceSpout(), 1);
    builder.setBolt("split", new SplitSentence(), 2).shuffleGrouping("spout");
    builder.setBolt("count", new WordCount(), 2).fieldsGrouping("split", new Fields("word"));
    Config conf = new Config();
    // component resource configuration
    conf.setComponentRam("spout", ByteAmount.fromMegabytes(512));
    conf.setComponentRam("split", ByteAmount.fromMegabytes(512));
    conf.setComponentRam("count", ByteAmount.fromMegabytes(512));
    // container resource configuration
    conf.setContainerDiskRequested(ByteAmount.fromGigabytes(3));
    conf.setContainerRamRequested(ByteAmount.fromGigabytes(3));
    conf.setContainerCpuRequested(2);
    conf.setNumStmgrs(2);
    HeronSubmitter.submitTopology(name, 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 30 with Config

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

the class StatefulSlidingWindowTopology method main.

public static void main(String[] args) throws Exception {
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("integer", new IntegerSpout(), 1);
    builder.setBolt("sumbolt", new WindowSumBolt().withWindow(BaseWindowedBolt.Count.of(5), BaseWindowedBolt.Count.of(3)), 1).shuffleGrouping("integer");
    builder.setBolt("printer", new PrinterBolt()).shuffleGrouping("sumbolt");
    Config conf = new Config();
    conf.setDebug(true);
    String topoName = "test";
    Config.setComponentRam(conf, "integer", ByteAmount.fromGigabytes(1));
    Config.setComponentRam(conf, "sumbolt", ByteAmount.fromGigabytes(1));
    Config.setComponentRam(conf, "printer", ByteAmount.fromGigabytes(1));
    Config.setContainerDiskRequested(conf, ByteAmount.fromGigabytes(5));
    Config.setContainerCpuRequested(conf, 4);
    conf.setTopologyReliabilityMode(Config.TopologyReliabilityMode.EFFECTIVELY_ONCE);
    conf.setTopologyStatefulCheckpointIntervalSecs(20);
    conf.setMaxSpoutPending(1000);
    if (args != null && args.length > 0) {
        topoName = args[0];
    }
    HeronSubmitter.submitTopology(topoName, conf, builder.createTopology());
}
Also used : TopologyBuilder(com.twitter.heron.api.topology.TopologyBuilder) Config(com.twitter.heron.api.Config) PrinterBolt(com.twitter.heron.examples.api.bolt.PrinterBolt)

Aggregations

Config (com.twitter.heron.api.Config)80 Test (org.junit.Test)39 TopologyBuilder (com.twitter.heron.api.topology.TopologyBuilder)25 HashMap (java.util.HashMap)22 Fields (com.twitter.heron.api.tuple.Fields)14 TopologyAPI (com.twitter.heron.api.generated.TopologyAPI)12 EcoTopologyDefinition (com.twitter.heron.eco.definition.EcoTopologyDefinition)12 TreeMap (java.util.TreeMap)12 ByteAmount (com.twitter.heron.common.basics.ByteAmount)9 FileInputStream (java.io.FileInputStream)9 EcoParser (com.twitter.heron.eco.parser.EcoParser)8 ByteArrayInputStream (java.io.ByteArrayInputStream)8 InputStream (java.io.InputStream)8 Map (java.util.Map)6 TopologyArgParser (com.github.ashvina.common.TopologyArgParser)5 TopologyContext (com.twitter.heron.api.topology.TopologyContext)5 Tuple (com.twitter.heron.api.tuple.Tuple)5 TestTopologyBuilder (com.twitter.heron.integration_test.core.TestTopologyBuilder)4 LinkedList (java.util.LinkedList)4 List (java.util.List)4