use of com.twitter.heron.api.Config in project incubator-heron by apache.
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)));
}
use of com.twitter.heron.api.Config in project incubator-heron by apache.
the class TopologyUtilsTest method testGetComponentRamMapSomeRamSpecified.
@Test
public void testGetComponentRamMapSomeRamSpecified() {
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);
ByteAmount spoutRam = ByteAmount.fromGigabytes(2);
topologyConfig.setComponentRam("spout", spoutRam);
// sort the component ram map
Map<String, ByteAmount> ramMap = new TreeMap<>(TopologyUtils.getComponentRamMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
// Component ram map sets only spout's ram
Assert.assertArrayEquals(new String[] { "spout" }, ramMap.keySet().toArray());
Assert.assertArrayEquals(new ByteAmount[] { spoutRam }, ramMap.values().toArray());
}
use of com.twitter.heron.api.Config in project incubator-heron by apache.
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();
}
use of com.twitter.heron.api.Config in project incubator-heron by apache.
the class ConfigBuilderTest method testBuildConfig_SpecifyingComponentResources_ReturnsCorrectValues.
@Test
public void testBuildConfig_SpecifyingComponentResources_ReturnsCorrectValues() throws Exception {
EcoParser ecoParser = new EcoParser();
InputStream inputStream = new ByteArrayInputStream(YAML_PROPERTIES.getBytes());
FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
EcoTopologyDefinition ecoTopologyDefinition = ecoParser.parseFromInputStream(inputStream, mockPropsStream, false);
Config config = subject.buildConfig(ecoTopologyDefinition);
assertThat(config.get(Config.TOPOLOGY_COMPONENT_RAMMAP), is(equalTo("spout-1:256000000,bolt-1:256000000")));
}
use of com.twitter.heron.api.Config in project incubator-heron by apache.
the class ConfigBuilderTest method testBuildConfig_IncorrectGBResourceFormat_ExceptionThrow.
@Test(expected = IllegalArgumentException.class)
public void testBuildConfig_IncorrectGBResourceFormat_ExceptionThrow() throws Exception {
Config config = null;
try {
EcoParser ecoParser = new EcoParser();
InputStream inputStream = new ByteArrayInputStream(INCORRECT_GB_FORMAT_YAML.getBytes());
FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
EcoTopologyDefinition ecoTopologyDefinition = ecoParser.parseFromInputStream(inputStream, mockPropsStream, false);
config = subject.buildConfig(ecoTopologyDefinition);
} finally {
assertNull(config);
}
}
Aggregations