Search in sources :

Example 1 with BuilderUtility

use of org.apache.heron.eco.builder.BuilderUtility in project heron by twitter.

the class Eco method submit.

/**
 * Submit an ECO topology
 *
 * @param fileInputStream  The input stream associated with ECO topology definition file
 * @param propertiesFile  The optional key-value property file for optional property substitution.
 * @param envFilter The optional flag to tell ECO to perform environment variable substitution
 * @throws Exception the exception thrown
 */
public void submit(FileInputStream fileInputStream, FileInputStream propertiesFile, boolean envFilter) throws Exception {
    EcoTopologyDefinition topologyDefinition = ecoParser.parseFromInputStream(fileInputStream, propertiesFile, envFilter);
    String topologyName = topologyDefinition.getName();
    String topologyType = topologyDefinition.getType();
    if ("storm".equals(topologyType)) {
        System.out.println("topology type is Storm");
        org.apache.heron.eco.builder.storm.EcoBuilder ecoBuilder = new org.apache.heron.eco.builder.storm.EcoBuilder(new org.apache.heron.eco.builder.storm.SpoutBuilder(), new BoltBuilder(), new org.apache.heron.eco.builder.storm.StreamBuilder(), new ComponentBuilder(), new ConfigBuilder());
        Config topologyConfig = ecoBuilder.buildConfig(topologyDefinition);
        EcoExecutionContext executionContext = new EcoExecutionContext(topologyDefinition, topologyConfig);
        printTopologyInfo(executionContext);
        ObjectBuilder objectBuilder = new ObjectBuilder();
        objectBuilder.setBuilderUtility(new BuilderUtility());
        org.apache.storm.topology.TopologyBuilder builder = ecoBuilder.buildTopologyBuilder(executionContext, objectBuilder);
        ecoSubmitter.submitStormTopology(topologyName, topologyConfig, builder.createTopology());
    } else if ("heron".equals(topologyType)) {
        System.out.println("topology type is Heron");
        org.apache.heron.eco.builder.heron.EcoBuilder ecoBuilder = new org.apache.heron.eco.builder.heron.EcoBuilder(new org.apache.heron.eco.builder.heron.SpoutBuilder(), new BoltBuilder(), new org.apache.heron.eco.builder.heron.StreamBuilder(), new ComponentBuilder(), new ConfigBuilder());
        Config topologyConfig = ecoBuilder.buildConfig(topologyDefinition);
        EcoExecutionContext executionContext = new EcoExecutionContext(topologyDefinition, topologyConfig);
        printTopologyInfo(executionContext);
        ObjectBuilder objectBuilder = new ObjectBuilder();
        objectBuilder.setBuilderUtility(new BuilderUtility());
        org.apache.heron.api.topology.TopologyBuilder builder = ecoBuilder.buildTopologyBuilder(executionContext, objectBuilder);
        ecoSubmitter.submitHeronTopology(topologyName, topologyConfig, builder.createTopology());
    } else {
        LOG.log(Level.SEVERE, String.format("Unknown topology type \'%s\' for topology %s, not submitted", topologyType, topologyName));
    }
}
Also used : Config(org.apache.heron.api.Config) EcoTopologyDefinition(org.apache.heron.eco.definition.EcoTopologyDefinition) BuilderUtility(org.apache.heron.eco.builder.BuilderUtility) BoltBuilder(org.apache.heron.eco.builder.BoltBuilder) ConfigBuilder(org.apache.heron.eco.builder.ConfigBuilder) EcoExecutionContext(org.apache.heron.eco.definition.EcoExecutionContext) ObjectBuilder(org.apache.heron.eco.builder.ObjectBuilder) ComponentBuilder(org.apache.heron.eco.builder.ComponentBuilder)

Aggregations

Config (org.apache.heron.api.Config)1 BoltBuilder (org.apache.heron.eco.builder.BoltBuilder)1 BuilderUtility (org.apache.heron.eco.builder.BuilderUtility)1 ComponentBuilder (org.apache.heron.eco.builder.ComponentBuilder)1 ConfigBuilder (org.apache.heron.eco.builder.ConfigBuilder)1 ObjectBuilder (org.apache.heron.eco.builder.ObjectBuilder)1 EcoExecutionContext (org.apache.heron.eco.definition.EcoExecutionContext)1 EcoTopologyDefinition (org.apache.heron.eco.definition.EcoTopologyDefinition)1