use of com.twitter.heron.spi.packing.PackingPlan in project heron by twitter.
the class PackingPlanBuilderTest method testAddToPackingPlan.
@Test
public void testAddToPackingPlan() throws ResourceExceededException {
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 com.twitter.heron.spi.packing.PackingPlan in project heron by twitter.
the class PackingPlanBuilderTest method testInvalidComponentRemoveFromPackingPlan.
@Test(expected = PackingException.class)
public void testInvalidComponentRemoveFromPackingPlan() throws ResourceExceededException {
PackingPlan plan = doCreatePackingPlanTest(testContainerInstances);
@SuppressWarnings({ "unchecked", "rawtypes" }) Pair<Integer, String>[] removed = new Pair[] { new Pair<>(1, "componentC") };
PackingTestHelper.removeFromTestPackingPlan(TOPOLOGY_ID, plan, removed, 0);
}
use of com.twitter.heron.spi.packing.PackingPlan in project heron by twitter.
the class ResourceCompliantRRPackingTest method testInsufficientContainersWithOneAdjustment.
/**
* Test the scenario where the user defined number of containers is not sufficient.
*/
@Test
public void testInsufficientContainersWithOneAdjustment() throws Exception {
int numContainers = 1;
// Set up the topology and its config
topologyConfig.put(com.twitter.heron.api.Config.TOPOLOGY_STMGRS, numContainers);
// Explicit set resources for container
ByteAmount containerRam = ByteAmount.fromGigabytes(2);
topologyConfig.setContainerRamRequested(containerRam);
TopologyAPI.Topology newTopology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
PackingPlan packingPlan = pack(newTopology);
Assert.assertEquals(7, packingPlan.getContainers().size());
Assert.assertEquals(totalInstances, packingPlan.getInstanceCount());
}
use of com.twitter.heron.spi.packing.PackingPlan 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);
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);
}
use of com.twitter.heron.spi.packing.PackingPlan in project heron by twitter.
the class CommonPackingTests 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.put(com.twitter.heron.api.Config.TOPOLOGY_STMGRS, 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());
}
}
}
Aggregations