Search in sources :

Example 1 with InstanceId

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

Example 2 with InstanceId

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

Example 3 with InstanceId

use of org.apache.heron.spi.packing.InstanceId in project heron by twitter.

the class ResourceCompliantRRPackingTest method testScaleDownOneComponentRemoveContainer.

/**
 * Test the scenario where scaling down removes instances from containers that are most imbalanced
 * (i.e., tending towards homogeneity) first. If there is a tie (e.g. AABB, AB), chooses from the
 * container with the fewest instances, to favor ultimately removing  containers. If there is
 * still a tie, favor removing from higher numbered containers
 */
@Test
public void testScaleDownOneComponentRemoveContainer() throws Exception {
    @SuppressWarnings({ "unchecked", "rawtypes" }) Pair<Integer, InstanceId>[] initialComponentInstances = new Pair[] { new Pair<>(1, new InstanceId(SPOUT_NAME, 1, 0)), new Pair<>(1, new InstanceId(SPOUT_NAME, 2, 1)), new Pair<>(1, new InstanceId(BOLT_NAME, 3, 0)), new Pair<>(3, new InstanceId(BOLT_NAME, 4, 1)), new Pair<>(3, new InstanceId(BOLT_NAME, 5, 2)), new Pair<>(4, new InstanceId(BOLT_NAME, 6, 3)), new Pair<>(4, new InstanceId(BOLT_NAME, 7, 4)) };
    Map<String, Integer> componentChanges = new HashMap<>();
    componentChanges.put(BOLT_NAME, -2);
    @SuppressWarnings({ "unchecked", "rawtypes" }) Pair<Integer, InstanceId>[] expectedComponentInstances = new Pair[] { new Pair<>(1, new InstanceId(SPOUT_NAME, 1, 0)), new Pair<>(1, new InstanceId(SPOUT_NAME, 2, 1)), new Pair<>(1, new InstanceId(BOLT_NAME, 3, 0)), new Pair<>(3, new InstanceId(BOLT_NAME, 4, 1)), new Pair<>(3, new InstanceId(BOLT_NAME, 5, 2)) };
    doScaleDownTest(initialComponentInstances, componentChanges, expectedComponentInstances);
}
Also used : InstanceId(org.apache.heron.spi.packing.InstanceId) HashMap(java.util.HashMap) Pair(org.apache.heron.common.basics.Pair) Test(org.junit.Test)

Example 4 with InstanceId

use of org.apache.heron.spi.packing.InstanceId in project heron by twitter.

the class ResourceCompliantRRPackingTest method testScaleDownTwoComponentsRemoveContainer.

@Test
public void testScaleDownTwoComponentsRemoveContainer() throws Exception {
    @SuppressWarnings({ "unchecked", "rawtypes" }) Pair<Integer, InstanceId>[] initialComponentInstances = new Pair[] { new Pair<>(1, new InstanceId(SPOUT_NAME, 1, 0)), new Pair<>(1, new InstanceId(SPOUT_NAME, 2, 1)), new Pair<>(1, new InstanceId(BOLT_NAME, 3, 0)), new Pair<>(1, new InstanceId(BOLT_NAME, 4, 1)), new Pair<>(3, new InstanceId(SPOUT_NAME, 5, 2)), new Pair<>(3, new InstanceId(SPOUT_NAME, 6, 3)), new Pair<>(3, new InstanceId(BOLT_NAME, 7, 2)), new Pair<>(3, new InstanceId(BOLT_NAME, 8, 3)) };
    Map<String, Integer> componentChanges = new HashMap<>();
    componentChanges.put(SPOUT_NAME, -2);
    componentChanges.put(BOLT_NAME, -2);
    @SuppressWarnings({ "unchecked", "rawtypes" }) Pair<Integer, InstanceId>[] expectedComponentInstances = new Pair[] { new Pair<>(1, new InstanceId(SPOUT_NAME, 1, 0)), new Pair<>(1, new InstanceId(SPOUT_NAME, 2, 1)), new Pair<>(1, new InstanceId(BOLT_NAME, 3, 0)), new Pair<>(1, new InstanceId(BOLT_NAME, 4, 1)) };
    doScaleDownTest(initialComponentInstances, componentChanges, expectedComponentInstances);
}
Also used : InstanceId(org.apache.heron.spi.packing.InstanceId) HashMap(java.util.HashMap) Pair(org.apache.heron.common.basics.Pair) Test(org.junit.Test)

Example 5 with InstanceId

use of org.apache.heron.spi.packing.InstanceId in project heron by twitter.

the class FirstFitDecreasingPackingTest method testScaleDownTwoComponentsRemoveContainer.

@Test
public void testScaleDownTwoComponentsRemoveContainer() throws Exception {
    @SuppressWarnings({ "unchecked", "rawtypes" }) Pair<Integer, InstanceId>[] initialComponentInstances = new Pair[] { new Pair<>(1, new InstanceId(SPOUT_NAME, 1, 0)), new Pair<>(1, new InstanceId(SPOUT_NAME, 2, 1)), new Pair<>(1, new InstanceId(BOLT_NAME, 3, 0)), new Pair<>(1, new InstanceId(BOLT_NAME, 4, 1)), new Pair<>(3, new InstanceId(SPOUT_NAME, 5, 2)), new Pair<>(3, new InstanceId(SPOUT_NAME, 6, 3)), new Pair<>(3, new InstanceId(BOLT_NAME, 7, 2)), new Pair<>(3, new InstanceId(BOLT_NAME, 8, 3)) };
    Map<String, Integer> componentChanges = new HashMap<>();
    componentChanges.put(SPOUT_NAME, -2);
    componentChanges.put(BOLT_NAME, -2);
    @SuppressWarnings({ "unchecked", "rawtypes" }) Pair<Integer, InstanceId>[] expectedComponentInstances = new Pair[] { new Pair<>(1, new InstanceId(SPOUT_NAME, 1, 0)), new Pair<>(1, new InstanceId(SPOUT_NAME, 2, 1)), new Pair<>(1, new InstanceId(BOLT_NAME, 3, 0)), new Pair<>(1, new InstanceId(BOLT_NAME, 4, 1)) };
    doScaleDownTest(initialComponentInstances, componentChanges, expectedComponentInstances);
}
Also used : InstanceId(org.apache.heron.spi.packing.InstanceId) HashMap(java.util.HashMap) Pair(org.apache.heron.common.basics.Pair) Test(org.junit.Test)

Aggregations

InstanceId (org.apache.heron.spi.packing.InstanceId)17 HashMap (java.util.HashMap)11 Pair (org.apache.heron.common.basics.Pair)10 Test (org.junit.Test)10 PackingPlan (org.apache.heron.spi.packing.PackingPlan)8 ArrayList (java.util.ArrayList)4 Resource (org.apache.heron.spi.packing.Resource)4 HashSet (java.util.HashSet)3 List (java.util.List)3 Map (java.util.Map)2 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 ByteAmount (org.apache.heron.common.basics.ByteAmount)1 InstanceConstraint (org.apache.heron.packing.constraints.InstanceConstraint)1 MinRamConstraint (org.apache.heron.packing.constraints.MinRamConstraint)1 PackingConstraint (org.apache.heron.packing.constraints.PackingConstraint)1 ResourceConstraint (org.apache.heron.packing.constraints.ResourceConstraint)1 PackingException (org.apache.heron.spi.packing.PackingException)1