Search in sources :

Example 41 with Config

use of org.apache.heron.api.Config in project heron by twitter.

the class AbstractTupleRoutingTest method constructPhysicalPlan.

private PhysicalPlans.PhysicalPlan constructPhysicalPlan() {
    PhysicalPlans.PhysicalPlan.Builder physicalPlanBuilder = PhysicalPlans.PhysicalPlan.newBuilder();
    // Set topology protobuf
    TopologyBuilder topologyBuilder = new TopologyBuilder();
    initSpout(topologyBuilder, Component.SPOUT.getName());
    initBoltA(topologyBuilder, Component.BOLT_A.getName(), Component.SPOUT.getName());
    initBoltB(topologyBuilder, Component.BOLT_B.getName(), Component.BOLT_A.getName());
    Config conf = new Config();
    conf.setTeamEmail("some-team@company.com");
    conf.setTeamName("some-team");
    conf.setTopologyProjectName("heron-integration-test");
    conf.setNumStmgrs(1);
    conf.setMaxSpoutPending(100);
    conf.setTopologyReliabilityMode(Config.TopologyReliabilityMode.ATMOST_ONCE);
    TopologyAPI.Topology topology = topologyBuilder.createTopology().setName("topology-name").setConfig(conf).setState(TopologyAPI.TopologyState.RUNNING).getTopology();
    physicalPlanBuilder.setTopology(topology);
    // Set instances
    int taskId = 0;
    for (Component component : Component.values()) {
        addComponent(physicalPlanBuilder, component, taskId++);
    }
    // Set stream mgr
    PhysicalPlans.StMgr.Builder stmgr = PhysicalPlans.StMgr.newBuilder();
    stmgr.setId("stream-manager-id");
    stmgr.setHostName("127.0.0.1");
    stmgr.setDataPort(8888);
    stmgr.setLocalEndpoint("endpoint");
    physicalPlanBuilder.addStmgrs(stmgr);
    return physicalPlanBuilder.build();
}
Also used : TopologyBuilder(org.apache.heron.api.topology.TopologyBuilder) Config(org.apache.heron.api.Config) TopologyAPI(org.apache.heron.api.generated.TopologyAPI)

Example 42 with Config

use of org.apache.heron.api.Config in project heron by twitter.

the class TopologyUtilsTest method testGetComponentRamMapDefaultValue.

@Test
public void testGetComponentRamMapDefaultValue() {
    int componentParallelism = 2;
    Config topologyConfig = new Config();
    Map<String, Integer> spouts = new HashMap<>();
    spouts.put("spout", componentParallelism);
    Map<String, Integer> bolts = new HashMap<>();
    bolts.put("bolt", componentParallelism);
    // sort the component RAM map
    Map<String, ByteAmount> ramMap = new TreeMap<>(TopologyUtils.getComponentRamMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
    // Component RAM map is not set, the ramMap size should be 0
    Assert.assertEquals(0, ramMap.size());
}
Also used : ByteAmount(org.apache.heron.common.basics.ByteAmount) HashMap(java.util.HashMap) Config(org.apache.heron.api.Config) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 43 with Config

use of org.apache.heron.api.Config in project heron by twitter.

the class TopologyUtilsTest method testValidTopology.

@Test
public void testValidTopology() {
    int componentParallelism = 2;
    Map<String, Integer> spouts = new HashMap<>();
    spouts.put("spout", componentParallelism);
    Map<String, Integer> bolts = new HashMap<>();
    bolts.put("bolt", componentParallelism);
    Map<String, String> connections = new HashMap<>();
    connections.put("bolt", "spout");
    Assert.assertTrue(TopologyUtils.verifyTopology(TopologyTests.createTopologyWithConnection("testTopology", /* Bad topology name */
    new Config(), spouts, bolts, connections)));
}
Also used : HashMap(java.util.HashMap) Config(org.apache.heron.api.Config) Test(org.junit.Test)

Example 44 with Config

use of org.apache.heron.api.Config in project heron by twitter.

the class HeronEcoBuilderTest method testBuild_EmptyConfigMap_ReturnsDefaultConfigs.

@Test
public void testBuild_EmptyConfigMap_ReturnsDefaultConfigs() throws Exception {
    Config config = new Config();
    when(mockConfigBuilder.buildConfig(eq(ecoTopologyDefinition))).thenReturn(config);
    Config returnedConfig = subject.buildConfig(ecoTopologyDefinition);
    verify(mockConfigBuilder).buildConfig(same(ecoTopologyDefinition));
    assertThat(returnedConfig.get(Config.TOPOLOGY_DEBUG), is(nullValue()));
    assertThat(config, sameInstance(returnedConfig));
}
Also used : Config(org.apache.heron.api.Config) Test(org.junit.Test)

Example 45 with Config

use of org.apache.heron.api.Config in project heron by twitter.

the class EcoSubmitterTest method submitStormTopology_AllGood_BehavesAsExpected.

@Test
public void submitStormTopology_AllGood_BehavesAsExpected() throws Exception {
    Config config = new Config();
    StormTopology topology = new StormTopology();
    PowerMockito.spy(StormSubmitter.class);
    PowerMockito.doNothing().when(StormSubmitter.class, "submitTopology", any(String.class), any(Config.class), any(StormTopology.class));
    subject.submitStormTopology("name", config, topology);
    PowerMockito.verifyStatic(times(1));
    StormSubmitter.submitTopology(anyString(), any(Config.class), any(StormTopology.class));
}
Also used : Config(org.apache.heron.api.Config) StormTopology(org.apache.storm.generated.StormTopology) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Config (org.apache.heron.api.Config)74 Test (org.junit.Test)35 TopologyBuilder (org.apache.heron.api.topology.TopologyBuilder)21 HashMap (java.util.HashMap)16 EcoTopologyDefinition (org.apache.heron.eco.definition.EcoTopologyDefinition)10 TreeMap (java.util.TreeMap)9 ByteArrayInputStream (java.io.ByteArrayInputStream)8 FileInputStream (java.io.FileInputStream)8 InputStream (java.io.InputStream)8 Fields (org.apache.heron.api.tuple.Fields)7 EcoParser (org.apache.heron.eco.parser.EcoParser)7 Map (java.util.Map)6 TopologyAPI (org.apache.heron.api.generated.TopologyAPI)6 ByteAmount (org.apache.heron.common.basics.ByteAmount)6 Simulator (org.apache.heron.simulator.Simulator)6 LinkedList (java.util.LinkedList)5 List (java.util.List)5 TopologyContext (org.apache.heron.api.topology.TopologyContext)5 Tuple (org.apache.heron.api.tuple.Tuple)5 TestWordSpout (org.apache.heron.examples.api.spout.TestWordSpout)5