use of org.apache.heron.common.basics.ByteAmount in project heron by twitter.
the class ResourceCompliantRRPackingTest method testInsufficientContainersWithMultipleAdjustments.
/**
* Test the scenario where the user defined number of containers is not sufficient.
*/
@Test
public void testInsufficientContainersWithMultipleAdjustments() throws Exception {
int numContainers = 1;
// Set up the topology and its config
topologyConfig.setNumStmgrs(numContainers);
// Explicit set resources for container
ByteAmount containerRam = ByteAmount.fromGigabytes(3);
// Explicit set component RAM map
ByteAmount boltRam = ByteAmount.fromGigabytes(1);
ByteAmount spoutRam = ByteAmount.fromGigabytes(2);
topologyConfig.setContainerRamRequested(containerRam);
topologyConfig.setComponentRam(BOLT_NAME, boltRam);
topologyConfig.setComponentRam(SPOUT_NAME, spoutRam);
topology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
doPackingTest(topology, instanceDefaultResources.cloneWithRam(boltRam), boltParallelism, instanceDefaultResources.cloneWithRam(spoutRam), spoutParallelism, 7, getDefaultMaxContainerResource().cloneWithRam(containerRam));
}
use of org.apache.heron.common.basics.ByteAmount in project heron by twitter.
the class ResourceCompliantRRPackingTest method testCompleteRamMapRequested.
/**
* Test the scenario RAM map config is partially set
*/
@Test
public void testCompleteRamMapRequested() throws Exception {
int numContainers = 3;
// Explicit set resources for container
// the value should be ignored, since we set the complete component RAM map
ByteAmount containerRam = ByteAmount.fromGigabytes(Long.MAX_VALUE);
// Explicit set component RAM map
ByteAmount boltRam = ByteAmount.fromGigabytes(1);
topologyConfig.setContainerRamRequested(containerRam);
topologyConfig.setComponentRam(BOLT_NAME, boltRam);
topology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
doPackingTest(topology, instanceDefaultResources.cloneWithRam(boltRam), boltParallelism, instanceDefaultResources, spoutParallelism, numContainers, getDefaultMaxContainerResource().cloneWithRam(containerRam));
}
use of org.apache.heron.common.basics.ByteAmount in project heron by twitter.
the class RoundRobinPackingTest method testPartialRamMap.
/**
* Test the scenario RAM map config is partially set
*/
@Test
public void testPartialRamMap() throws Exception {
// Explicit set resources for container
ByteAmount containerRam = ByteAmount.fromGigabytes(10);
// Explicit set component RAM map
ByteAmount boltRam = ByteAmount.fromGigabytes(1);
topologyConfig.setContainerRamRequested(containerRam);
topologyConfig.setComponentRam(BOLT_NAME, boltRam);
topology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
doPackingTestWithPartialResource(topology, Optional.of(boltRam), Optional.empty(), boltParallelism, Optional.empty(), Optional.empty(), spoutParallelism, numContainers, getDefaultPadding(), getDefaultUnspecifiedContainerResource(boltParallelism + spoutParallelism, numContainers, getDefaultPadding()).cloneWithRam(containerRam));
}
use of org.apache.heron.common.basics.ByteAmount in project heron by twitter.
the class RoundRobinPackingTest method testCompleteRamMapRequestedWithExactlyEnoughResource.
/**
* Test the scenario RAM map config is completely set
*/
@Test
public void testCompleteRamMapRequestedWithExactlyEnoughResource() throws Exception {
// Explicit set resources for container
// the value should be ignored, since we set the complete component RAM map
ByteAmount containerRam = ByteAmount.fromGigabytes(8);
// Explicit set component RAM map
ByteAmount boltRam = ByteAmount.fromGigabytes(1);
ByteAmount spoutRam = ByteAmount.fromGigabytes(2);
topologyConfig.setContainerRamRequested(containerRam);
topologyConfig.setComponentRam(BOLT_NAME, boltRam);
topologyConfig.setComponentRam(SPOUT_NAME, spoutRam);
topology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
doPackingTestWithPartialResource(topology, Optional.of(boltRam), Optional.empty(), boltParallelism, Optional.of(spoutRam), Optional.empty(), spoutParallelism, numContainers, getDefaultPadding(), getDefaultUnspecifiedContainerResource(boltParallelism + spoutParallelism, numContainers, getDefaultPadding()).cloneWithRam(containerRam));
}
use of org.apache.heron.common.basics.ByteAmount in project heron by twitter.
the class PackingUtils method computeTotalResourceChange.
/**
* Identifies the resources reclaimed by the components that will be scaled down
*
* @return Total resources reclaimed
*/
public static Resource computeTotalResourceChange(TopologyAPI.Topology topology, Map<String, Integer> componentChanges, Resource defaultInstanceResources, ScalingDirection scalingDirection) {
double cpu = 0;
ByteAmount ram = ByteAmount.ZERO;
ByteAmount disk = ByteAmount.ZERO;
Map<String, ByteAmount> ramMap = TopologyUtils.getComponentRamMapConfig(topology);
Map<String, Integer> componentsToScale = PackingUtils.getComponentsToScale(componentChanges, scalingDirection);
for (String component : componentsToScale.keySet()) {
int parallelismChange = Math.abs(componentChanges.get(component));
cpu += parallelismChange * defaultInstanceResources.getCpu();
disk = disk.plus(defaultInstanceResources.getDisk().multiply(parallelismChange));
if (ramMap.containsKey(component)) {
ram = ram.plus(ramMap.get(component).multiply(parallelismChange));
} else {
ram = ram.plus(defaultInstanceResources.getRam().multiply(parallelismChange));
}
}
return new Resource(cpu, ram, disk);
}
Aggregations