use of org.apache.heron.eco.definition.BoltDefinition in project heron by twitter.
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 org.apache.heron.eco.definition.BoltDefinition in project heron by twitter.
the class Eco method printTopologyInfo.
static void printTopologyInfo(EcoExecutionContext ctx) {
EcoTopologyDefinition t = ctx.getTopologyDefinition();
LOG.info("---------- TOPOLOGY DETAILS ----------");
LOG.info(String.format("Topology Name: %s", t.getName()));
LOG.info("--------------- SPOUTS ---------------");
for (SpoutDefinition s : t.getSpouts()) {
LOG.info(String.format("%s [%d] (%s)", s.getId(), s.getParallelism(), s.getClassName()));
}
LOG.info("---------------- BOLTS ---------------");
for (BoltDefinition b : t.getBolts()) {
LOG.info(String.format("%s [%d] (%s)", b.getId(), b.getParallelism(), b.getClassName()));
}
LOG.info("--------------- STREAMS ---------------");
for (StreamDefinition sd : t.getStreams()) {
LOG.info(String.format("%s --%s--> %s", sd.getFrom(), sd.getGrouping().getType(), sd.getTo()));
}
LOG.info("--------------------------------------");
}
use of org.apache.heron.eco.definition.BoltDefinition in project heron by twitter.
the class EcoParserTest method testParseFromInputStream_VerifyAllButComponents_MapsAsExpected.
@Test
public void testParseFromInputStream_VerifyAllButComponents_MapsAsExpected() throws Exception {
InputStream inputStream = new ByteArrayInputStream(YAML_STR.getBytes());
FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
EcoTopologyDefinition topologyDefinition = subject.parseFromInputStream(inputStream, mockPropsStream, false);
assertEquals("yaml-topology", topologyDefinition.getName());
assertEquals(1, topologyDefinition.getConfig().size());
assertEquals(1, topologyDefinition.getConfig().get("topology.workers"));
BoltDefinition bolt1 = topologyDefinition.getBolt(BOLT_1);
assertNotNull(bolt1);
assertEquals(2, bolt1.getParallelism());
assertEquals("org.apache.heron.sample.TestWordCounter", bolt1.getClassName());
assertEquals(BOLT_1, bolt1.getId());
BoltDefinition bolt2 = topologyDefinition.getBolt(BOLT_2);
assertEquals(1, bolt2.getParallelism());
assertEquals("org.apache.heron.sample.LogInfoBolt", bolt2.getClassName());
assertEquals(BOLT_2, bolt2.getId());
List<StreamDefinition> streamDefinitions = topologyDefinition.getStreams();
StreamDefinition streamDefinitionOne = streamDefinitions.get(0);
GroupingDefinition groupingDefinitionOne = streamDefinitionOne.getGrouping();
StreamDefinition streamDefinitionTwo = streamDefinitions.get(1);
GroupingDefinition groupingDefinitionTwo = streamDefinitionTwo.getGrouping();
assertEquals(2, streamDefinitions.size());
assertEquals(BOLT_1, streamDefinitionOne.getTo());
assertEquals("spout-1", streamDefinitionOne.getFrom());
assertEquals(GroupingDefinition.Type.FIELDS, groupingDefinitionOne.getType());
assertEquals(1, groupingDefinitionOne.getArgs().size());
assertEquals("word", groupingDefinitionOne.getArgs().get(0));
assertEquals("connection-1", streamDefinitionOne.getId());
assertEquals(BOLT_2, streamDefinitionTwo.getTo());
assertEquals("bolt-1", streamDefinitionTwo.getFrom());
assertEquals(GroupingDefinition.Type.SHUFFLE, groupingDefinitionTwo.getType());
assertEquals("connection-2", streamDefinitionTwo.getId());
assertNull(groupingDefinitionTwo.getArgs());
}
use of org.apache.heron.eco.definition.BoltDefinition in project heron by twitter.
the class EcoParserTest method testParseFromInputStream_PropertyFiltering_SubstitutesAsExpected.
@Test
public void testParseFromInputStream_PropertyFiltering_SubstitutesAsExpected() throws Exception {
InputStream inputStream = new ByteArrayInputStream(PROPERTY_SUBSTITUION_YAML.getBytes());
InputStream propsStream = new ByteArrayInputStream(SAMPLE_PROPERTIES.getBytes());
EcoTopologyDefinition ecoTopologyDefinition = subject.parseFromInputStream(inputStream, propsStream, false);
BoltDefinition bolt = ecoTopologyDefinition.getBolt("ibasic-print-bolt");
List<Object> args = bolt.getConfigMethods().get(0).getArgs();
assertThat(args.get(0), is(equalTo("ecoValueOne")));
}
Aggregations