use of com.twitter.heron.eco.definition.SpoutDefinition in project incubator-heron by apache.
the class SpoutBuilderTest method testBuildSpouts_AllGood_BehavesAsExpected.
@Test
public void testBuildSpouts_AllGood_BehavesAsExpected() throws ClassNotFoundException, InvocationTargetException, NoSuchFieldException, InstantiationException, IllegalAccessException {
EcoTopologyDefinition topologyDefinition = new EcoTopologyDefinition();
SpoutDefinition spoutDefinition = new SpoutDefinition();
final String id = "id";
final int parallelism = 2;
spoutDefinition.setId(id);
spoutDefinition.setParallelism(parallelism);
SpoutDefinition spoutDefinition1 = new SpoutDefinition();
final String id1 = "id1";
final int parallelism1 = 3;
spoutDefinition1.setId(id1);
spoutDefinition1.setParallelism(parallelism1);
List<SpoutDefinition> spoutDefinitions = new ArrayList<>();
spoutDefinitions.add(spoutDefinition);
spoutDefinitions.add(spoutDefinition1);
topologyDefinition.setSpouts(spoutDefinitions);
MockSpout mockSpout = new MockSpout();
MockSpout mockSpout1 = new MockSpout();
when(mockObjectBuilder.buildObject(eq(spoutDefinition), eq(mockContext))).thenReturn(mockSpout);
when(mockObjectBuilder.buildObject(eq(spoutDefinition1), eq(mockContext))).thenReturn(mockSpout1);
when(mockContext.getTopologyDefinition()).thenReturn(topologyDefinition);
subject.buildSpouts(mockContext, mockTopologyBuilder, mockObjectBuilder);
verify(mockContext).getTopologyDefinition();
verify(mockObjectBuilder).buildObject(same(spoutDefinition), same(mockContext));
verify(mockObjectBuilder).buildObject(same(spoutDefinition1), same(mockContext));
verify(mockTopologyBuilder).setSpout(eq(id), eq(mockSpout), eq(parallelism));
verify(mockTopologyBuilder).setSpout(eq(id1), eq(mockSpout1), eq(parallelism1));
verify(mockContext).addSpout(eq(id), anyObject());
verify(mockContext).addSpout(eq(id1), anyObject());
}
use of com.twitter.heron.eco.definition.SpoutDefinition in project incubator-heron by apache.
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("--------------------------------------");
}
Aggregations