use of org.apache.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 org.apache.heron.api.Config in project heron by twitter.
the class TopologyUtilsTest method testGetComponentDiskMapSomeDiskSpecified.
@Test
public void testGetComponentDiskMapSomeDiskSpecified() {
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 spoutDisk = ByteAmount.fromGigabytes(2);
topologyConfig.setComponentDisk("spout", spoutDisk);
// sort the component disk map
Map<String, ByteAmount> diskMap = new TreeMap<>(TopologyUtils.getComponentDiskMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
// Component disk map sets only spout's disk
Assert.assertArrayEquals(new String[] { "spout" }, diskMap.keySet().toArray());
Assert.assertArrayEquals(new ByteAmount[] { spoutDisk }, diskMap.values().toArray());
}
use of org.apache.heron.api.Config in project heron by twitter.
the class TopologyUtilsTest method testBadTopologyName.
@Test
public void testBadTopologyName() {
int componentParallelism = 2;
Map<String, Integer> spouts = new HashMap<>();
spouts.put("spout", componentParallelism);
Map<String, Integer> bolts = new HashMap<>();
bolts.put("bolt", componentParallelism);
Assert.assertFalse(TopologyUtils.verifyTopology(TopologyTests.createTopology("test.topology", /* Bad topology name */
new Config(), spouts, bolts)));
}
use of org.apache.heron.api.Config in project heron by twitter.
the class TopologyUtilsTest method testGetComponentParallelism.
@Test
public void testGetComponentParallelism() {
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);
Map<String, Integer> componentParallelismMap = TopologyUtils.getComponentParallelism(topology);
Assert.assertEquals(componentParallelism, componentParallelismMap.get("spout").intValue());
Assert.assertEquals(componentParallelism, componentParallelismMap.get("bolt").intValue());
}
use of org.apache.heron.api.Config in project heron by twitter.
the class TopologyUtilsTest method testGetComponentRamMapAllRamSpecified.
@Test
public void testGetComponentRamMapAllRamSpecified() {
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 boltRam = ByteAmount.fromGigabytes(1);
ByteAmount spoutRam = ByteAmount.fromGigabytes(2);
topologyConfig.setComponentRam("spout", spoutRam);
topologyConfig.setComponentRam("bolt", boltRam);
// sort the component RAM map
Map<String, ByteAmount> ramMap = new TreeMap<>(TopologyUtils.getComponentRamMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
Assert.assertArrayEquals(new String[] { "bolt", "spout" }, ramMap.keySet().toArray());
Assert.assertArrayEquals(new ByteAmount[] { boltRam, spoutRam }, ramMap.values().toArray());
}
Aggregations