Search in sources :

Example 1 with SpoutDefinition

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

Example 2 with SpoutDefinition

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

Aggregations

EcoTopologyDefinition (com.twitter.heron.eco.definition.EcoTopologyDefinition)2 SpoutDefinition (com.twitter.heron.eco.definition.SpoutDefinition)2 BoltDefinition (com.twitter.heron.eco.definition.BoltDefinition)1 StreamDefinition (com.twitter.heron.eco.definition.StreamDefinition)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1