use of org.apache.heron.spi.packing.PackingPlan in project heron by twitter.
the class PackingPlanBuilderTest method testAddToPackingPlan.
@Test
public void testAddToPackingPlan() throws ConstraintViolationException {
PackingPlan plan = doCreatePackingPlanTest(testContainerInstances);
@SuppressWarnings({ "unchecked", "rawtypes" }) Pair<Integer, InstanceId>[] added = new Pair[] { new Pair<>(1, new InstanceId("componentB", 4, 1)), new Pair<>(4, new InstanceId("componentA", 5, 2)) };
PackingPlan updatedPlan = PackingTestHelper.addToTestPackingPlan(TOPOLOGY_ID, plan, PackingTestHelper.toContainerIdComponentNames(added), 0);
Pair<Integer, InstanceId>[] expected = concat(testContainerInstances, added);
AssertPacking.assertPackingPlan(TOPOLOGY_ID, expected, updatedPlan);
}
use of org.apache.heron.spi.packing.PackingPlan in project heron by twitter.
the class PackingPlanBuilderTest method testRemoveFromPackingPlan.
@Test
public void testRemoveFromPackingPlan() throws ConstraintViolationException {
PackingPlan plan = doCreatePackingPlanTest(testContainerInstances);
@SuppressWarnings({ "unchecked", "rawtypes" }) Pair<Integer, String>[] removed = new Pair[] { new Pair<>(1, "componentA"), new Pair<>(3, "componentA") };
PackingPlan updatedPlan = PackingTestHelper.removeFromTestPackingPlan(TOPOLOGY_ID, plan, removed, 0);
@SuppressWarnings({ "unchecked", "rawtypes" }) Pair<Integer, InstanceId>[] expected = new Pair[] { new Pair<>(3, new InstanceId("componentB", 3, 0)) };
AssertPacking.assertPackingPlan(TOPOLOGY_ID, expected, updatedPlan);
}
use of org.apache.heron.spi.packing.PackingPlan in project heron by twitter.
the class ResourceCompliantRRPackingTest method doTestContainerCountRequested.
/**
* Test the scenario where container level resource config are set
*/
protected void doTestContainerCountRequested(int requestedContainers, int expectedContainer) throws Exception {
// Explicit set resources for container
topologyConfig.setContainerRamRequested(ByteAmount.fromGigabytes(10));
topologyConfig.setContainerDiskRequested(ByteAmount.fromGigabytes(20));
topologyConfig.setContainerCpuRequested(30);
topologyConfig.setNumStmgrs(requestedContainers);
TopologyAPI.Topology topologyExplicitResourcesConfig = getTopology(spoutParallelism, boltParallelism, topologyConfig);
PackingPlan packingPlanExplicitResourcesConfig = pack(topologyExplicitResourcesConfig);
Assert.assertEquals(expectedContainer, packingPlanExplicitResourcesConfig.getContainers().size());
Assert.assertEquals(totalInstances, packingPlanExplicitResourcesConfig.getInstanceCount());
// RAM for bolt/spout should be the value in component RAM map
for (PackingPlan.ContainerPlan containerPlan : packingPlanExplicitResourcesConfig.getContainers()) {
for (PackingPlan.InstancePlan instancePlan : containerPlan.getInstances()) {
Assert.assertEquals(instanceDefaultResources, instancePlan.getResource());
}
}
}
use of org.apache.heron.spi.packing.PackingPlan in project heron by twitter.
the class RoundRobinPackingTest method testContainerRequestedResourcesWhenRamPaddingSet.
/**
* Test the scenario container level resource config are set
*/
@Test
public void testContainerRequestedResourcesWhenRamPaddingSet() throws Exception {
// Explicit set resources for container
ByteAmount containerRam = ByteAmount.fromGigabytes(10);
ByteAmount containerDisk = ByteAmount.fromGigabytes(20);
double containerCpu = 30;
ByteAmount containerRamPadding = ByteAmount.fromMegabytes(512);
Resource containerResource = new Resource(containerCpu, containerRam, containerDisk);
topologyConfig.setContainerRamRequested(containerRam);
topologyConfig.setContainerDiskRequested(containerDisk);
topologyConfig.setContainerCpuRequested(containerCpu);
topologyConfig.setContainerRamPadding(containerRamPadding);
topology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
PackingPlan packingPlan = doPackingTestWithPartialResource(topology, Optional.empty(), Optional.empty(), boltParallelism, Optional.empty(), Optional.empty(), spoutParallelism, numContainers, getDefaultPadding().cloneWithRam(containerRamPadding), containerResource);
for (PackingPlan.ContainerPlan containerPlan : packingPlan.getContainers()) {
// 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());
int instancesCount = containerPlan.getInstances().size();
Assert.assertEquals(containerRam.minus(containerRamPadding).divide(instancesCount), resources.iterator().next().getRam());
Assert.assertEquals((containerCpu - RoundRobinPacking.DEFAULT_CPU_PADDING_PER_CONTAINER) / instancesCount, resources.iterator().next().getCpu(), DELTA);
}
}
use of org.apache.heron.spi.packing.PackingPlan in project heron by twitter.
the class RoundRobinPackingTest method testFullRamMapWithoutContainerRequestedResources.
@Test
public void testFullRamMapWithoutContainerRequestedResources() 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;
ByteAmount spoutRam = ByteAmount.fromMegabytes(500);
ByteAmount boltRam = ByteAmount.fromMegabytes(1000);
Resource containerResource = new Resource(containerCpu, containerRam, containerDisk);
// Don't set container RAM
topologyConfig.setContainerDiskRequested(containerDisk);
topologyConfig.setContainerCpuRequested(containerCpu);
topologyConfig.setComponentRam(SPOUT_NAME, spoutRam);
topologyConfig.setComponentRam(BOLT_NAME, boltRam);
topology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
PackingPlan packingPlan = doPackingTestWithPartialResource(topology, Optional.of(boltRam), Optional.empty(), boltParallelism, Optional.of(spoutRam), 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());
}
// Bolt and spout ram sizes are both fixed.
Assert.assertEquals(2, differentResources.size());
}
}
Aggregations