use of com.twitter.heron.spi.packing.PackingPlan in project heron by twitter.
the class CommonPackingTests method scaleDownAndUp.
/**
* Test the scenario where scaling down and up is simultaneously requested
*/
@Test
public void scaleDownAndUp() throws Exception {
int spoutScalingDown = -4;
int boltScalingUp = 6;
Map<String, Integer> componentChanges = new HashMap<>();
// 0 spouts
componentChanges.put(SPOUT_NAME, spoutScalingDown);
// 9 bolts
componentChanges.put(BOLT_NAME, boltScalingUp);
int numContainersBeforeRepack = 2;
PackingPlan newPackingPlan = doDefaultScalingTest(componentChanges, numContainersBeforeRepack);
Assert.assertEquals(3, newPackingPlan.getContainers().size());
Assert.assertEquals((Integer) (totalInstances + spoutScalingDown + boltScalingUp), newPackingPlan.getInstanceCount());
AssertPacking.assertNumInstances(newPackingPlan.getContainers(), BOLT_NAME, 9);
AssertPacking.assertNumInstances(newPackingPlan.getContainers(), SPOUT_NAME, 0);
}
use of com.twitter.heron.spi.packing.PackingPlan in project heron by twitter.
the class FirstFitDecreasingPackingTest method testPartialRamMapScaling.
/**
* Test the scenario ram map config is partially set and scaling is requested
*/
@Test
public void testPartialRamMapScaling() throws Exception {
ByteAmount boltRam = ByteAmount.fromGigabytes(4);
ByteAmount maxContainerRam = ByteAmount.fromGigabytes(10);
topologyConfig.setContainerMaxRamHint(maxContainerRam);
topologyConfig.setComponentRam(BOLT_NAME, boltRam);
TopologyAPI.Topology topologyExplicitRamMap = getTopology(spoutParallelism, boltParallelism, topologyConfig);
int numScalingInstances = 3;
Map<String, Integer> componentChanges = new HashMap<>();
componentChanges.put(BOLT_NAME, numScalingInstances);
int numContainersBeforeRepack = 2;
PackingPlan newPackingPlan = doScalingTest(topologyExplicitRamMap, componentChanges, boltRam, boltParallelism, instanceDefaultResources.getRam(), spoutParallelism, numContainersBeforeRepack, totalInstances);
Assert.assertEquals(4, newPackingPlan.getContainers().size());
Assert.assertEquals((Integer) (totalInstances + numScalingInstances), newPackingPlan.getInstanceCount());
AssertPacking.assertContainers(newPackingPlan.getContainers(), BOLT_NAME, SPOUT_NAME, boltRam, instanceDefaultResources.getRam(), null);
}
use of com.twitter.heron.spi.packing.PackingPlan in project heron by twitter.
the class FirstFitDecreasingPackingTest method testDefaultContainerSizeRepack.
/**
* Test the scenario where the max container size is the default
* and scaling is requested.
*/
@Test
public void testDefaultContainerSizeRepack() throws Exception {
int defaultNumInstancesperContainer = 4;
int numScalingInstances = 5;
Map<String, Integer> componentChanges = new HashMap<>();
componentChanges.put(BOLT_NAME, numScalingInstances);
int numContainersBeforeRepack = 2;
PackingPlan newPackingPlan = doDefaultScalingTest(componentChanges, numContainersBeforeRepack);
Assert.assertEquals(3, newPackingPlan.getContainers().size());
Assert.assertEquals((Integer) (totalInstances + numScalingInstances), newPackingPlan.getInstanceCount());
AssertPacking.assertContainers(newPackingPlan.getContainers(), BOLT_NAME, SPOUT_NAME, instanceDefaultResources.getRam(), instanceDefaultResources.getRam(), null);
for (PackingPlan.ContainerPlan containerPlan : newPackingPlan.getContainers()) {
Assert.assertEquals(Math.round(PackingUtils.increaseBy(defaultNumInstancesperContainer * instanceDefaultResources.getCpu(), DEFAULT_CONTAINER_PADDING)), (long) containerPlan.getRequiredResource().getCpu());
Assert.assertEquals(instanceDefaultResources.getRam().multiply(defaultNumInstancesperContainer).increaseBy(DEFAULT_CONTAINER_PADDING), containerPlan.getRequiredResource().getRam());
Assert.assertEquals(instanceDefaultResources.getDisk().multiply(defaultNumInstancesperContainer).increaseBy(DEFAULT_CONTAINER_PADDING), containerPlan.getRequiredResource().getDisk());
}
}
use of com.twitter.heron.spi.packing.PackingPlan in project heron by twitter.
the class FirstFitDecreasingPackingTest method scaleDownAndUpWithExtraPadding.
/**
* Test the scenario where scaling down and up is simultaneously requested and padding is
* configured
*/
@Test
public void scaleDownAndUpWithExtraPadding() throws Exception {
int paddingPercentage = 50;
topologyConfig.setContainerPaddingPercentage(paddingPercentage);
ByteAmount spoutRam = ByteAmount.fromGigabytes(2);
ByteAmount maxContainerRam = ByteAmount.fromGigabytes(12);
topologyConfig.setContainerMaxRamHint(maxContainerRam);
topologyConfig.setComponentRam(SPOUT_NAME, spoutRam);
int noBolts = 2;
int noSpouts = 1;
TopologyAPI.Topology topologyExplicitRamMap = getTopology(noSpouts, noBolts, topologyConfig);
int spoutScalingUp = 1;
int boltScalingDown = -2;
Map<String, Integer> componentChanges = new HashMap<>();
// 2 spouts
componentChanges.put(SPOUT_NAME, spoutScalingUp);
// 0 bolts
componentChanges.put(BOLT_NAME, boltScalingDown);
int numContainersBeforeRepack = 1;
PackingPlan newPackingPlan = doScalingTest(topologyExplicitRamMap, componentChanges, instanceDefaultResources.getRam(), noBolts, spoutRam, noSpouts, numContainersBeforeRepack, noSpouts + noBolts);
Assert.assertEquals(1, 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);
}
use of com.twitter.heron.spi.packing.PackingPlan in project heron by twitter.
the class FirstFitDecreasingPackingTest method testDefaultContainerSizeWithPadding.
/**
* Test the scenario where the max container size is the default but padding is configured
*/
@Test
public void testDefaultContainerSizeWithPadding() throws Exception {
int padding = 50;
int defaultNumInstancesperContainer = 4;
topologyConfig.setContainerPaddingPercentage(padding);
TopologyAPI.Topology newTopology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
PackingPlan packingPlan = pack(newTopology);
Assert.assertEquals(2, packingPlan.getContainers().size());
Assert.assertEquals(totalInstances, packingPlan.getInstanceCount());
ByteAmount defaultRam = instanceDefaultResources.getRam().multiply(defaultNumInstancesperContainer).increaseBy(padding);
AssertPacking.assertContainerRam(packingPlan.getContainers(), defaultRam);
AssertPacking.assertNumInstances(packingPlan.getContainers(), BOLT_NAME, 3);
AssertPacking.assertNumInstances(packingPlan.getContainers(), SPOUT_NAME, 4);
}
Aggregations