Search in sources :

Example 51 with PackingPlan

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);
}
Also used : InstanceId(com.twitter.heron.spi.packing.InstanceId) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) Pair(com.twitter.heron.common.basics.Pair) Test(org.junit.Test)

Example 52 with PackingPlan

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);
}
Also used : PackingPlan(com.twitter.heron.spi.packing.PackingPlan) Pair(com.twitter.heron.common.basics.Pair) Test(org.junit.Test)

Example 53 with PackingPlan

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());
}
Also used : ByteAmount(com.twitter.heron.common.basics.ByteAmount) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) TopologyAPI(com.twitter.heron.api.generated.TopologyAPI) Test(org.junit.Test)

Example 54 with PackingPlan

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);
}
Also used : ByteAmount(com.twitter.heron.common.basics.ByteAmount) HashMap(java.util.HashMap) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) TopologyAPI(com.twitter.heron.api.generated.TopologyAPI) Test(org.junit.Test)

Example 55 with PackingPlan

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());
        }
    }
}
Also used : PackingPlan(com.twitter.heron.spi.packing.PackingPlan) TopologyAPI(com.twitter.heron.api.generated.TopologyAPI)

Aggregations

PackingPlan (com.twitter.heron.spi.packing.PackingPlan)87 Test (org.junit.Test)63 TopologyAPI (com.twitter.heron.api.generated.TopologyAPI)34 ByteAmount (com.twitter.heron.common.basics.ByteAmount)27 HashSet (java.util.HashSet)22 HashMap (java.util.HashMap)20 Config (com.twitter.heron.spi.common.Config)18 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)13 Resource (com.twitter.heron.spi.packing.Resource)10 InstanceId (com.twitter.heron.spi.packing.InstanceId)7 SchedulerStateManagerAdaptor (com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor)7 Pair (com.twitter.heron.common.basics.Pair)6 RoundRobinPacking (com.twitter.heron.packing.roundrobin.RoundRobinPacking)5 PackingPlanProtoDeserializer (com.twitter.heron.spi.packing.PackingPlanProtoDeserializer)4 EvaluatorRequest (org.apache.reef.driver.evaluator.EvaluatorRequest)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 PackingPlans (com.twitter.heron.proto.system.PackingPlans)3 LauncherUtils (com.twitter.heron.scheduler.utils.LauncherUtils)3 ContainerPlan (com.twitter.heron.spi.packing.PackingPlan.ContainerPlan)3 PackingPlanProtoSerializer (com.twitter.heron.spi.packing.PackingPlanProtoSerializer)3