use of com.twitter.heron.spi.packing.PackingPlan in project heron by twitter.
the class FirstFitDecreasingPackingTest method testDefaultContainerSize.
/**
* Test the scenario where the max container size is the default
*/
@Test
public void testDefaultContainerSize() throws Exception {
int defaultNumInstancesperContainer = 4;
PackingPlan packingPlan = pack(topology);
Assert.assertEquals(2, packingPlan.getContainers().size());
Assert.assertEquals(totalInstances, packingPlan.getInstanceCount());
ByteAmount defaultRam = instanceDefaultResources.getRam().multiply(defaultNumInstancesperContainer).increaseBy(DEFAULT_CONTAINER_PADDING);
AssertPacking.assertContainerRam(packingPlan.getContainers(), defaultRam);
AssertPacking.assertNumInstances(packingPlan.getContainers(), BOLT_NAME, 3);
AssertPacking.assertNumInstances(packingPlan.getContainers(), SPOUT_NAME, 4);
}
use of com.twitter.heron.spi.packing.PackingPlan in project heron by twitter.
the class FirstFitDecreasingPackingTest method testCompleteRamMapRequested.
/**
* Test the scenario ram map config is fully set
*/
@Test
public void testCompleteRamMapRequested() throws Exception {
// Explicit set max resources for container
// the value should be ignored, since we set the complete component ram map
ByteAmount maxContainerRam = ByteAmount.fromGigabytes(15);
ByteAmount maxContainerDisk = ByteAmount.fromGigabytes(20);
float maxContainerCpu = 30;
// Explicit set component ram map
ByteAmount boltRam = ByteAmount.fromGigabytes(1);
ByteAmount spoutRam = ByteAmount.fromGigabytes(2);
topologyConfig.setContainerMaxRamHint(maxContainerRam);
topologyConfig.setContainerMaxDiskHint(maxContainerDisk);
topologyConfig.setContainerMaxCpuHint(maxContainerCpu);
topologyConfig.setComponentRam(BOLT_NAME, boltRam);
topologyConfig.setComponentRam(SPOUT_NAME, spoutRam);
TopologyAPI.Topology topologyExplicitRamMap = getTopology(spoutParallelism, boltParallelism, topologyConfig);
PackingPlan packingPlanExplicitRamMap = pack(topologyExplicitRamMap);
Assert.assertEquals(1, packingPlanExplicitRamMap.getContainers().size());
Assert.assertEquals(totalInstances, packingPlanExplicitRamMap.getInstanceCount());
AssertPacking.assertNumInstances(packingPlanExplicitRamMap.getContainers(), BOLT_NAME, 3);
AssertPacking.assertNumInstances(packingPlanExplicitRamMap.getContainers(), SPOUT_NAME, 4);
AssertPacking.assertContainers(packingPlanExplicitRamMap.getContainers(), BOLT_NAME, SPOUT_NAME, boltRam, spoutRam, maxContainerRam);
AssertPacking.assertContainerRam(packingPlanExplicitRamMap.getContainers(), maxContainerRam);
}
use of com.twitter.heron.spi.packing.PackingPlan in project heron by twitter.
the class FirstFitDecreasingPackingTest method testPartialRamMapWithPadding.
/**
* Test the scenario ram map config is partially set and padding is configured
*/
@Test
public void testPartialRamMapWithPadding() throws Exception {
topologyConfig.setContainerPaddingPercentage(0);
// Explicit set resources for container
ByteAmount maxContainerRam = ByteAmount.fromGigabytes(10);
// Explicit set component ram map
ByteAmount boltRam = ByteAmount.fromGigabytes(4);
topologyConfig.setContainerMaxRamHint(maxContainerRam);
topologyConfig.setComponentRam(BOLT_NAME, boltRam);
TopologyAPI.Topology topologyExplicitRamMap = getTopology(spoutParallelism, boltParallelism, topologyConfig);
PackingPlan packingPlanExplicitRamMap = pack(topologyExplicitRamMap);
Assert.assertEquals(2, packingPlanExplicitRamMap.getContainers().size());
Assert.assertEquals(totalInstances, packingPlanExplicitRamMap.getInstanceCount());
AssertPacking.assertNumInstances(packingPlanExplicitRamMap.getContainers(), BOLT_NAME, 3);
AssertPacking.assertNumInstances(packingPlanExplicitRamMap.getContainers(), SPOUT_NAME, 4);
AssertPacking.assertContainers(packingPlanExplicitRamMap.getContainers(), BOLT_NAME, SPOUT_NAME, boltRam, instanceDefaultResources.getRam(), null);
AssertPacking.assertContainerRam(packingPlanExplicitRamMap.getContainers(), maxContainerRam);
}
use of com.twitter.heron.spi.packing.PackingPlan in project heron by twitter.
the class FirstFitDecreasingPackingTest 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.setContainerMaxRamHint(maxContainerRam);
TopologyAPI.Topology topologyExplicitRamMap = getTopology(spoutParallelism, boltParallelism, topologyConfig);
int numScalingInstances = 3;
Map<String, Integer> componentChanges = new HashMap<>();
componentChanges.put(BOLT_NAME, numScalingInstances);
int numContainersBeforeRepack = 3;
PackingPlan newPackingPlan = doScalingTest(topologyExplicitRamMap, componentChanges, boltRam, boltParallelism, instanceDefaultResources.getRam(), spoutParallelism, numContainersBeforeRepack, totalInstances);
Assert.assertEquals(6, newPackingPlan.getContainers().size());
Assert.assertEquals((Integer) (totalInstances + numScalingInstances), newPackingPlan.getInstanceCount());
AssertPacking.assertContainers(newPackingPlan.getContainers(), BOLT_NAME, SPOUT_NAME, boltRam, instanceDefaultResources.getRam(), null);
for (PackingPlan.ContainerPlan containerPlan : newPackingPlan.getContainers()) {
//Each container either contains a single bolt or 1 bolt and 2 spouts
if (containerPlan.getInstances().size() == 1) {
Assert.assertEquals(boltRam.increaseBy(paddingPercentage), containerPlan.getRequiredResource().getRam());
}
if (containerPlan.getInstances().size() == 3) {
ByteAmount resourceRam = boltRam.plus(instanceDefaultResources.getRam().multiply(2));
Assert.assertEquals(resourceRam.increaseBy(paddingPercentage), containerPlan.getRequiredResource().getRam());
}
}
}
use of com.twitter.heron.spi.packing.PackingPlan in project heron by twitter.
the class FirstFitDecreasingPackingTest 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;
topologyConfig.setContainerPaddingPercentage(paddingPercentage);
ByteAmount spoutRam = ByteAmount.fromGigabytes(4);
ByteAmount maxContainerRam = ByteAmount.fromGigabytes(12);
topologyConfig.setContainerMaxRamHint(maxContainerRam);
topologyConfig.setComponentRam(SPOUT_NAME, spoutRam);
int noBolts = 3;
int noSpouts = 1;
TopologyAPI.Topology topologyExplicitRamMap = getTopology(noSpouts, noBolts, 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 = 1;
PackingPlan newPackingPlan = doScalingTest(topologyExplicitRamMap, componentChanges, instanceDefaultResources.getRam(), noBolts, spoutRam, noSpouts, numContainersBeforeRepack, noSpouts + noBolts);
Assert.assertEquals(2, newPackingPlan.getContainers().size());
Assert.assertEquals((Integer) (noSpouts + noBolts + spoutScalingUp + boltScalingDown), newPackingPlan.getInstanceCount());
AssertPacking.assertNumInstances(newPackingPlan.getContainers(), BOLT_NAME, noBolts + boltScalingDown);
AssertPacking.assertNumInstances(newPackingPlan.getContainers(), SPOUT_NAME, noSpouts + spoutScalingUp);
}
Aggregations