use of org.apache.heron.common.basics.ByteAmount in project heron by twitter.
the class ResourceCompliantRRPackingTest method testContainerRequestedResourcesSingleContainer.
/**
* Test the scenario where container level resource config are set
*/
@Test
public void testContainerRequestedResourcesSingleContainer() throws Exception {
int numContainers = 1;
// Set up the topology and its config
topologyConfig.setNumStmgrs(numContainers);
// 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);
Resource padding = PackingUtils.finalizePadding(new Resource(containerCpu, containerRam, containerDisk), new Resource(PackingUtils.DEFAULT_CONTAINER_CPU_PADDING, PackingUtils.DEFAULT_CONTAINER_RAM_PADDING, PackingUtils.DEFAULT_CONTAINER_RAM_PADDING), PackingUtils.DEFAULT_CONTAINER_PADDING_PERCENTAGE);
topologyConfig.setContainerRamRequested(containerRam);
topologyConfig.setContainerDiskRequested(containerDisk);
topologyConfig.setContainerCpuRequested(containerCpu);
topology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
PackingPlan packingPlan = doPackingTest(topology, instanceDefaultResources, boltParallelism, instanceDefaultResources, spoutParallelism, numContainers, containerResource);
for (PackingPlan.ContainerPlan containerPlan : packingPlan.getContainers()) {
Assert.assertEquals(Math.round(totalInstances * instanceDefaultResources.getCpu() + padding.getCpu()), (long) containerPlan.getRequiredResource().getCpu());
Assert.assertEquals(instanceDefaultResources.getRam().multiply(totalInstances).plus(padding.getRam()), containerPlan.getRequiredResource().getRam());
Assert.assertEquals(instanceDefaultResources.getDisk().multiply(totalInstances).plus(padding.getDisk()), containerPlan.getRequiredResource().getDisk());
// All instances' resource requirement should be equal
// So the size of set should be 1
Set<Resource> resources = new HashSet<>();
for (PackingPlan.InstancePlan instancePlan : containerPlan.getInstances()) {
resources.add(instancePlan.getResource());
}
Assert.assertEquals(1, resources.size());
Assert.assertEquals(instanceDefaultResources.getRam(), resources.iterator().next().getRam());
}
}
use of org.apache.heron.common.basics.ByteAmount in project heron by twitter.
the class ResourceCompliantRRPackingTest method scaleDownAndUpNoPadding.
/**
* Test the scenario where scaling down and up is simultaneously requested and padding is
* configured
*/
@Test
public void scaleDownAndUpNoPadding() throws Exception {
int paddingPercentage = 0;
int numContainers = 1;
topologyConfig.setContainerPaddingPercentage(paddingPercentage);
// Explicit set resources for container
ByteAmount maxContainerRam = ByteAmount.fromGigabytes(12);
// Explicit set component RAM map
ByteAmount spoutRam = ByteAmount.fromGigabytes(4);
topologyConfig.setContainerRamRequested(maxContainerRam);
topologyConfig.setComponentRam(SPOUT_NAME, spoutRam);
topologyConfig.setNumStmgrs(numContainers);
boltParallelism = 3;
spoutParallelism = 1;
topology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
int spoutScalingUp = 1;
int boltScalingDown = -1;
Map<String, Integer> componentChanges = new HashMap<>();
// 2 spouts
componentChanges.put(SPOUT_NAME, spoutScalingUp);
// 2 bolts
componentChanges.put(BOLT_NAME, boltScalingDown);
int numContainersBeforeRepack = 2;
int numContainersAfterRepack = 2;
doPackingAndScalingTest(topology, componentChanges, instanceDefaultResources, boltParallelism, instanceDefaultResources.cloneWithRam(spoutRam), spoutParallelism, numContainersBeforeRepack, numContainersAfterRepack, getDefaultMaxContainerResource().cloneWithRam(maxContainerRam));
}
use of org.apache.heron.common.basics.ByteAmount in project heron by twitter.
the class ResourceCompliantRRPackingTest method testPartialRamMapScaling.
/**
* Test the scenario RAM map config is partially set and scaling is requested
*/
@Test
public void testPartialRamMapScaling() throws Exception {
// Explicit set resources for container
ByteAmount maxContainerRam = ByteAmount.fromGigabytes(10);
// Explicit set component RAM map
ByteAmount boltRam = ByteAmount.fromGigabytes(4);
topologyConfig.setContainerRamRequested(maxContainerRam);
topologyConfig.setComponentRam(BOLT_NAME, boltRam);
topology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
int numScalingInstances = 3;
Map<String, Integer> componentChanges = new HashMap<>();
componentChanges.put(BOLT_NAME, numScalingInstances);
int numContainersBeforeRepack = 3;
int numContainersAfterRepack = 4;
doPackingAndScalingTest(topology, componentChanges, instanceDefaultResources.cloneWithRam(boltRam), boltParallelism, instanceDefaultResources, spoutParallelism, numContainersBeforeRepack, numContainersAfterRepack, getDefaultMaxContainerResource().cloneWithRam(maxContainerRam));
}
use of org.apache.heron.common.basics.ByteAmount in project heron by twitter.
the class ResourceCompliantRRPackingTest method testRepackPadding.
/**
* Test the scenario RAM map config is partially set and scaling is requested
*/
@Test
public void testRepackPadding() throws Exception {
int paddingPercentage = 50;
topologyConfig.setContainerPaddingPercentage(paddingPercentage);
// Explicit set component RAM map
ByteAmount boltRam = ByteAmount.fromGigabytes(4);
ByteAmount maxContainerRam = ByteAmount.fromGigabytes(10);
topologyConfig.setComponentRam(BOLT_NAME, boltRam);
topologyConfig.setContainerRamRequested(maxContainerRam);
topology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
int numScalingInstances = 3;
Map<String, Integer> componentChanges = new HashMap<>();
componentChanges.put(BOLT_NAME, numScalingInstances);
int numContainersBeforeRepack = 4;
int numContainersAfterRepack = 6;
doPackingAndScalingTest(topology, componentChanges, instanceDefaultResources.cloneWithRam(boltRam), boltParallelism, instanceDefaultResources, spoutParallelism, numContainersBeforeRepack, numContainersAfterRepack, getDefaultMaxContainerResource().cloneWithRam(maxContainerRam));
}
use of org.apache.heron.common.basics.ByteAmount in project heron by twitter.
the class ResourceCompliantRRPackingTest method testPartialRamMap.
/**
* Test the scenario RAM map config is fully set
*/
@Test
public void testPartialRamMap() throws Exception {
int numContainers = 3;
// Explicit set resources for container
ByteAmount containerRam = ByteAmount.fromGigabytes(10);
// 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, numContainers, getDefaultMaxContainerResource().cloneWithRam(containerRam));
}
Aggregations