use of com.twitter.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());
}
use of com.twitter.heron.api.Config in project heron by twitter.
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 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)));
}
use of com.twitter.heron.api.Config in project heron by twitter.
the class TopologyUtilsTest method testGetTotalInstance.
@Test
public void testGetTotalInstance() {
int componentParallelism = 4;
Config topologyConfig = new Config();
Map<String, Integer> spouts = new HashMap<>();
spouts.put("spout", componentParallelism);
Map<String, Integer> bolts = new HashMap<>();
bolts.put("bolt", componentParallelism);
TopologyAPI.Topology topology = TopologyTests.createTopology("testTopology", topologyConfig, spouts, bolts);
Assert.assertEquals((spouts.size() + bolts.size()) * componentParallelism, TopologyUtils.getTotalInstance(topology));
}
use of com.twitter.heron.api.Config in project incubator-heron by apache.
the class ConfigUtils method translateComponentConfig.
/**
* Translate storm config to heron config for components
* @param stormConfig the storm config
* @return a heron config
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Config translateComponentConfig(Map stormConfig) {
Config heronConfig;
if (stormConfig != null) {
heronConfig = new Config((Map<String, Object>) stormConfig);
} else {
heronConfig = new Config();
}
doStormTranslation(heronConfig);
return heronConfig;
}
Aggregations