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));
}
}
Aggregations