use of org.apache.heron.api.Config in project heron by twitter.
the class TopologyUtilsTest method testGetComponentCpuMapSomeCpuSpecified.
@Test
public void testGetComponentCpuMapSomeCpuSpecified() {
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);
double spoutCpu = 2.0f;
topologyConfig.setComponentCpu("spout", spoutCpu);
// sort the component CPU map
Map<String, Double> cpuMap = new TreeMap<>(TopologyUtils.getComponentCpuMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
// Component CPU map sets only spout's CPU
Assert.assertArrayEquals(new String[] { "spout" }, cpuMap.keySet().toArray());
Assert.assertArrayEquals(new Double[] { spoutCpu }, cpuMap.values().toArray());
}
use of org.apache.heron.api.Config in project heron by twitter.
the class TopologyUtilsTest method testGetComponentCpuMapDefaultValue.
@Test
public void testGetComponentCpuMapDefaultValue() {
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 CPU map
Map<String, Double> cpuMap = new TreeMap<>(TopologyUtils.getComponentCpuMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
// Component CPU map is not set, the cpuMap size should be 0
Assert.assertEquals(0, cpuMap.size());
}
use of org.apache.heron.api.Config in project heron by twitter.
the class TopologyUtilsTest method testGetComponentDiskMapDefaultValue.
@Test
public void testGetComponentDiskMapDefaultValue() {
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 disk map
Map<String, ByteAmount> diskMap = new TreeMap<>(TopologyUtils.getComponentDiskMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
// Component disk map is not set, the diskMap size should be 0
Assert.assertEquals(0, diskMap.size());
}
use of org.apache.heron.api.Config in project heron by twitter.
the class TopologyUtilsTest method testGetComponentDiskMapAllDiskSpecified.
@Test
public void testGetComponentDiskMapAllDiskSpecified() {
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 boltDisk = ByteAmount.fromGigabytes(1);
ByteAmount spoutDisk = ByteAmount.fromGigabytes(2);
topologyConfig.setComponentDisk("spout", spoutDisk);
topologyConfig.setComponentDisk("bolt", boltDisk);
// sort the component disk map
Map<String, ByteAmount> diskMap = new TreeMap<>(TopologyUtils.getComponentDiskMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
Assert.assertArrayEquals(new String[] { "bolt", "spout" }, diskMap.keySet().toArray());
Assert.assertArrayEquals(new ByteAmount[] { boltDisk, spoutDisk }, diskMap.values().toArray());
}
use of org.apache.heron.api.Config in project heron by twitter.
the class HeronEcoBuilderTest method testBuildTopologyBuilder_BuildsAsExpected.
@Test
public void testBuildTopologyBuilder_BuildsAsExpected() throws IllegalAccessException, ClassNotFoundException, InstantiationException, NoSuchFieldException, InvocationTargetException {
Config config = new Config();
EcoExecutionContext context = new EcoExecutionContext(ecoTopologyDefinition, config);
ObjectBuilder objectBuilder = new ObjectBuilder();
subject.buildTopologyBuilder(context, objectBuilder);
verify(mockSpoutBuilder).buildSpouts(same(context), any(TopologyBuilder.class), same(objectBuilder));
verify(mockBoltBuilder).buildBolts(same(context), same(objectBuilder));
verify(mockStreamBuilder).buildStreams(same(context), any(TopologyBuilder.class), same(objectBuilder));
verify(mockComponentBuilder).buildComponents(same(context), same(objectBuilder));
}
Aggregations