use of org.apache.heron.common.basics.ByteAmount in project heron by twitter.
the class RoundRobinPackingTest method testHugePartialRamMapWithoutContainerRequestedResources.
// Throw an error if default container resource (default instance resource * number of instances
// + padding) is not enough.
@Test(expected = PackingException.class)
public void testHugePartialRamMapWithoutContainerRequestedResources() 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);
ByteAmount boltRam = ByteAmount.fromGigabytes(10);
// Don't set container RAM
topologyConfig.setContainerDiskRequested(containerDisk);
topologyConfig.setContainerCpuRequested(containerCpu);
topologyConfig.setComponentRam(BOLT_NAME, boltRam);
topology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
PackingPlan packingPlan = doPackingTestWithPartialResource(topology, Optional.of(boltRam), 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 RoundRobinPackingTest method testNoRamMapWithoutContainerRequestedResources.
@Test
public void testNoRamMapWithoutContainerRequestedResources() throws Exception {
// Explicit set resources for container
// max container resource is 6G
ByteAmount containerRam = ByteAmount.fromGigabytes(6);
ByteAmount containerDisk = ByteAmount.fromGigabytes(20);
double containerCpu = 30;
Resource containerResource = new Resource(containerCpu, containerRam, containerDisk);
// Container RAM is not set in config
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 RoundRobinPackingTest method testCompleteRamMapRequestedWithoutPaddingResource.
/**
* Test the scenario RAM map config is completely set
*/
@Test
public void testCompleteRamMapRequestedWithoutPaddingResource() throws Exception {
// Explicit set resources for container
// the value should be ignored, since we set the complete component RAM map
ByteAmount containerRam = ByteAmount.fromGigabytes(6);
// 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 RoundRobinPackingTest method testCompleteRamMapRequestedWithLessThanEnoughResource.
/**
* Test the scenario RAM map config is completely set
*/
@Test(expected = PackingException.class)
public void testCompleteRamMapRequestedWithLessThanEnoughResource() throws Exception {
// Explicit set resources for container
// the value should be ignored, since we set the complete component RAM map
ByteAmount containerRam = ByteAmount.fromGigabytes(2);
// 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 RoundRobinPackingTest method testCompleteRamMapRequestedWithMoreThanEnoughResource.
/**
* Test the scenario RAM map config is completely set
*/
@Test
public void testCompleteRamMapRequestedWithMoreThanEnoughResource() throws Exception {
// Explicit set resources for container
// the value should be ignored, since we set the complete component RAM map
ByteAmount containerRam = ByteAmount.fromBytes(Long.MAX_VALUE);
// 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));
}
Aggregations