use of com.twitter.heron.eco.definition.EcoTopologyDefinition in project incubator-heron by apache.
the class BoltBuilder method buildBolts.
protected void buildBolts(EcoExecutionContext executionContext, ObjectBuilder objectBuilder) throws IllegalAccessException, InstantiationException, ClassNotFoundException, NoSuchFieldException, InvocationTargetException {
EcoTopologyDefinition topologyDefinition = executionContext.getTopologyDefinition();
for (ObjectDefinition def : topologyDefinition.getBolts()) {
Object obj = objectBuilder.buildObject(def, executionContext);
executionContext.addBolt(def.getId(), obj);
}
}
use of com.twitter.heron.eco.definition.EcoTopologyDefinition 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());
}
use of com.twitter.heron.eco.definition.EcoTopologyDefinition in project incubator-heron by apache.
the class EcoTest method testSubmit_AllGood_BehavesAsExpected.
@Test
public void testSubmit_AllGood_BehavesAsExpected() throws Exception {
FileInputStream mockStream = PowerMockito.mock(FileInputStream.class);
FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
final String topologyName = "the name";
EcoTopologyDefinition topologyDefinition = new EcoTopologyDefinition();
topologyDefinition.setName(topologyName);
Config config = new Config();
when(mockEcoParser.parseFromInputStream(eq(mockStream), eq(mockPropsStream), eq(false))).thenReturn(topologyDefinition);
when(mockEcoBuilder.buildConfig(eq(topologyDefinition))).thenReturn(config);
when(mockEcoBuilder.buildTopologyBuilder(any(EcoExecutionContext.class), any(ObjectBuilder.class))).thenReturn(mockTopologyBuilder);
subject.submit(mockStream, mockPropsStream, false);
verify(mockEcoParser).parseFromInputStream(same(mockStream), same(mockPropsStream), eq(false));
verify(mockEcoBuilder).buildConfig(same(topologyDefinition));
verify(mockEcoBuilder).buildTopologyBuilder(any(EcoExecutionContext.class), any(ObjectBuilder.class));
verify(mockTopologyBuilder).createTopology();
verify(mockEcoSubmitter).submitTopology(any(String.class), any(Config.class), any(StormTopology.class));
}
use of com.twitter.heron.eco.definition.EcoTopologyDefinition in project incubator-heron by apache.
the class BoltBuilderTest method testBuildBolts_AllGood_BehavesAsExpected.
@Test
public void testBuildBolts_AllGood_BehavesAsExpected() throws ClassNotFoundException, InvocationTargetException, NoSuchFieldException, InstantiationException, IllegalAccessException {
EcoTopologyDefinition ecoTopologyDefinition = new EcoTopologyDefinition();
BoltDefinition boltDefinition = new BoltDefinition();
final String id = "id";
boltDefinition.setId(id);
BoltDefinition boltDefinition1 = new BoltDefinition();
final String id1 = "id1";
boltDefinition1.setId(id1);
List<BoltDefinition> boltDefinitions = new ArrayList<>();
boltDefinitions.add(boltDefinition);
boltDefinitions.add(boltDefinition1);
ecoTopologyDefinition.setBolts(boltDefinitions);
Object object = new Object();
Object object1 = new Object();
when(mockContext.getTopologyDefinition()).thenReturn(ecoTopologyDefinition);
when(mockObjectBuilder.buildObject(eq(boltDefinition), eq(mockContext))).thenReturn(object);
when(mockObjectBuilder.buildObject(eq(boltDefinition1), eq(mockContext))).thenReturn(object1);
subject.buildBolts(mockContext, mockObjectBuilder);
verify(mockContext).getTopologyDefinition();
verify(mockObjectBuilder).buildObject(same(boltDefinition), same(mockContext));
verify(mockObjectBuilder).buildObject(same(boltDefinition1), same(mockContext));
verify(mockContext).addBolt(eq(id), anyObject());
verify(mockContext).addBolt(eq(id1), anyObject());
}
use of com.twitter.heron.eco.definition.EcoTopologyDefinition in project incubator-heron by apache.
the class ConfigBuilderTest method testBuildConfig_IncorrectByteResourceFormat_ExceptionThrow.
@Test(expected = IllegalArgumentException.class)
public void testBuildConfig_IncorrectByteResourceFormat_ExceptionThrow() throws Exception {
Config config = null;
try {
EcoParser ecoParser = new EcoParser();
InputStream inputStream = new ByteArrayInputStream(INCORRECT_BYTES_FORMAT_YAML.getBytes());
FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
EcoTopologyDefinition ecoTopologyDefinition = ecoParser.parseFromInputStream(inputStream, mockPropsStream, false);
config = subject.buildConfig(ecoTopologyDefinition);
} finally {
assertNull(config);
}
}
Aggregations