Search in sources :

Example 11 with EcoTopologyDefinition

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);
    }
}
Also used : ObjectDefinition(com.twitter.heron.eco.definition.ObjectDefinition) EcoTopologyDefinition(com.twitter.heron.eco.definition.EcoTopologyDefinition)

Example 12 with EcoTopologyDefinition

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());
}
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 13 with EcoTopologyDefinition

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));
}
Also used : Config(com.twitter.heron.api.Config) StormTopology(org.apache.storm.generated.StormTopology) EcoExecutionContext(com.twitter.heron.eco.definition.EcoExecutionContext) EcoTopologyDefinition(com.twitter.heron.eco.definition.EcoTopologyDefinition) ObjectBuilder(com.twitter.heron.eco.builder.ObjectBuilder) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 14 with EcoTopologyDefinition

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());
}
Also used : BoltDefinition(com.twitter.heron.eco.definition.BoltDefinition) ArrayList(java.util.ArrayList) Matchers.anyObject(org.mockito.Matchers.anyObject) EcoTopologyDefinition(com.twitter.heron.eco.definition.EcoTopologyDefinition) Test(org.junit.Test)

Example 15 with EcoTopologyDefinition

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);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Config(com.twitter.heron.api.Config) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) EcoParser(com.twitter.heron.eco.parser.EcoParser) EcoTopologyDefinition(com.twitter.heron.eco.definition.EcoTopologyDefinition) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Aggregations

EcoTopologyDefinition (com.twitter.heron.eco.definition.EcoTopologyDefinition)26 Test (org.junit.Test)19 FileInputStream (java.io.FileInputStream)14 ByteArrayInputStream (java.io.ByteArrayInputStream)13 InputStream (java.io.InputStream)13 Config (com.twitter.heron.api.Config)12 EcoParser (com.twitter.heron.eco.parser.EcoParser)8 BoltDefinition (com.twitter.heron.eco.definition.BoltDefinition)4 StreamDefinition (com.twitter.heron.eco.definition.StreamDefinition)3 ArrayList (java.util.ArrayList)3 ObjectBuilder (com.twitter.heron.eco.builder.ObjectBuilder)2 BeanDefinition (com.twitter.heron.eco.definition.BeanDefinition)2 EcoExecutionContext (com.twitter.heron.eco.definition.EcoExecutionContext)2 GroupingDefinition (com.twitter.heron.eco.definition.GroupingDefinition)2 ObjectDefinition (com.twitter.heron.eco.definition.ObjectDefinition)2 SpoutDefinition (com.twitter.heron.eco.definition.SpoutDefinition)2 HashMap (java.util.HashMap)2 Matchers.anyObject (org.mockito.Matchers.anyObject)2 BuilderUtility (com.twitter.heron.eco.builder.BuilderUtility)1 BeanReference (com.twitter.heron.eco.definition.BeanReference)1