use of org.apache.heron.common.basics.ByteAmount in project heron by twitter.
the class FormatterUtils method renderResourceUsage.
public String renderResourceUsage(Resource resource) {
double cpu = resource.getCpu();
ByteAmount ram = resource.getRam();
ByteAmount disk = resource.getDisk();
return String.format("CPU: %s, RAM: %s MB, Disk: %s MB", cpu, ram.asMegabytes(), disk.asMegabytes());
}
use of org.apache.heron.common.basics.ByteAmount in project heron by twitter.
the class RoundRobinPackingTest method testZeroContainersFailure.
@Test(expected = RuntimeException.class)
public void testZeroContainersFailure() throws Exception {
// Explicit set insufficient RAM for container
ByteAmount containerRam = ByteAmount.fromGigabytes(10);
topologyConfig.setContainerRamRequested(containerRam);
topologyConfig.setNumStmgrs(0);
topology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
doPackingTest(topology, instanceDefaultResources, boltParallelism, instanceDefaultResources, spoutParallelism, // 0 containers
0, getDefaultUnspecifiedContainerResource(boltParallelism + spoutParallelism, numContainers, getDefaultPadding()).cloneWithRam(containerRam));
}
use of org.apache.heron.common.basics.ByteAmount in project heron by twitter.
the class RoundRobinPackingTest method testContainerRequestedResources.
/**
* Test the scenario container level resource config are set
*/
@Test
public void testContainerRequestedResources() throws Exception {
// Explicit set resources for container
ByteAmount containerRam = ByteAmount.fromGigabytes(10);
ByteAmount containerDisk = ByteAmount.fromGigabytes(20);
double containerCpu = 30;
Resource containerResource = new Resource(containerCpu, containerRam, containerDisk);
topologyConfig.setContainerRamRequested(containerRam);
topologyConfig.setContainerDiskRequested(containerDisk);
topologyConfig.setContainerCpuRequested(containerCpu);
topology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
PackingPlan packingPlan = doPackingTestWithPartialResource(topology, Optional.empty(), Optional.empty(), boltParallelism, Optional.empty(), Optional.empty(), spoutParallelism, numContainers, getDefaultPadding(), containerResource);
for (PackingPlan.ContainerPlan containerPlan : packingPlan.getContainers()) {
// All instances' resource requirement should be equal
// So the size of set should be 1
Set<Resource> differentResources = new HashSet<>();
for (PackingPlan.InstancePlan instancePlan : containerPlan.getInstances()) {
differentResources.add(instancePlan.getResource());
}
Assert.assertEquals(1, differentResources.size());
int instancesCount = containerPlan.getInstances().size();
Assert.assertEquals(containerRam.minus(RoundRobinPacking.DEFAULT_RAM_PADDING_PER_CONTAINER).divide(instancesCount), differentResources.iterator().next().getRam());
Assert.assertEquals((containerCpu - RoundRobinPacking.DEFAULT_CPU_PADDING_PER_CONTAINER) / instancesCount, differentResources.iterator().next().getCpu(), DELTA);
}
}
use of org.apache.heron.common.basics.ByteAmount 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.common.basics.ByteAmount 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());
}
Aggregations