Search in sources :

Example 6 with Pair

use of com.twitter.heron.common.basics.Pair in project incubator-heron by apache.

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 7 with Pair

use of com.twitter.heron.common.basics.Pair in project incubator-heron by apache.

the class CommonPackingTests method testScaleDownHomogenousFirst.

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

Example 8 with Pair

use of com.twitter.heron.common.basics.Pair in project incubator-heron by apache.

the class CommonPackingTests method testScaleDownTwoComponentsRemoveContainer.

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

Example 9 with Pair

use of com.twitter.heron.common.basics.Pair in project incubator-heron by apache.

the class UpdateDryRunRenderTest method setUp.

@Before
public void setUp() throws Exception {
    // set up original packing plan
    final String COMPONENT_A = "exclaim1";
    final String COMPONENT_B = "word";
    ContainerPlan containerPlanA = PackingTestUtils.testContainerPlan(1, new Pair<>(COMPONENT_A, 1), new Pair<>(COMPONENT_A, 3), new Pair<>(COMPONENT_B, 5));
    ContainerPlan containerPlanB = PackingTestUtils.testContainerPlan(2, new Pair<>(COMPONENT_A, 2), new Pair<>(COMPONENT_A, 4), new Pair<>(COMPONENT_B, 6));
    Set<ContainerPlan> containerPlans = new HashSet<>();
    containerPlans.add(containerPlanA);
    containerPlans.add(containerPlanB);
    originalPlan = new PackingPlan("ORIG", containerPlans);
    // setup new packing plan A: word:1, exclaim1:9
    Set<ContainerPlan> containerPlansA = new HashSet<>();
    containerPlansA.add(containerPlanA);
    containerPlansA.add(PackingTestUtils.testContainerPlan(2, new Pair<>(COMPONENT_A, 4), new Pair<>(COMPONENT_A, 2), new Pair<>(COMPONENT_A, 6)));
    containerPlansA.add(PackingTestUtils.testContainerPlan(3, new Pair<>(COMPONENT_A, 7), new Pair<>(COMPONENT_A, 8), new Pair<>(COMPONENT_A, 9)));
    containerPlansA.add(PackingTestUtils.testContainerPlan(4, new Pair<>(COMPONENT_A, 10)));
    newPlanA = new PackingPlan("A", containerPlansA);
    // setup new packing plan B: word:1, exclaim1:1
    Set<ContainerPlan> containerPlansB = new HashSet<>();
    containerPlansB.add(PackingTestUtils.testContainerPlan(1, new Pair<>(COMPONENT_A, 3), new Pair<>(COMPONENT_B, 5)));
    newPlanB = new PackingPlan("B", containerPlansB);
}
Also used : ContainerPlan(com.twitter.heron.spi.packing.PackingPlan.ContainerPlan) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) HashSet(java.util.HashSet) Pair(com.twitter.heron.common.basics.Pair) Before(org.junit.Before)

Example 10 with Pair

use of com.twitter.heron.common.basics.Pair in project incubator-heron by apache.

the class TopologyResource method updateComponentParallelism.

protected Response updateComponentParallelism(String cluster, String role, String environment, String name, MultivaluedMap<String, String> params, List<String> components) {
    final List<Pair<String, Object>> keyValues = new ArrayList<>(Arrays.asList(Pair.create(Key.CLUSTER.value(), cluster), Pair.create(Key.ROLE.value(), role), Pair.create(Key.ENVIRON.value(), environment), Pair.create(Key.TOPOLOGY_NAME.value(), name), Pair.create(Keys.PARAM_COMPONENT_PARALLELISM, String.join(",", components))));
    // has a dry run been requested?
    if (params.containsKey(PARAM_DRY_RUN)) {
        keyValues.add(Pair.create(Key.DRY_RUN.value(), Boolean.TRUE));
    }
    final Set<Pair<String, Object>> overrides = getUpdateOverrides(params);
    // apply overrides if they exists
    if (!overrides.isEmpty()) {
        keyValues.addAll(overrides);
    }
    final Config config = createConfig(keyValues);
    getActionFactory().createRuntimeAction(config, ActionType.UPDATE).execute();
    return Response.ok().type(MediaType.APPLICATION_JSON).entity(Utils.createMessage(String.format("%s updated", name))).build();
}
Also used : Config(com.twitter.heron.spi.common.Config) ArrayList(java.util.ArrayList) Pair(com.twitter.heron.common.basics.Pair)

Aggregations

Pair (com.twitter.heron.common.basics.Pair)27 Test (org.junit.Test)18 InstanceId (com.twitter.heron.spi.packing.InstanceId)12 PackingPlan (com.twitter.heron.spi.packing.PackingPlan)12 HashMap (java.util.HashMap)7 InetSocketAddress (java.net.InetSocketAddress)6 Config (com.twitter.heron.spi.common.Config)5 ArrayList (java.util.ArrayList)4 ContainerPlan (com.twitter.heron.spi.packing.PackingPlan.ContainerPlan)2 NetworkUtils (com.twitter.heron.spi.utils.NetworkUtils)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 List (java.util.List)2 POST (javax.ws.rs.POST)2 Produces (javax.ws.rs.Produces)2 Before (org.junit.Before)2 Mockito.anyString (org.mockito.Mockito.anyString)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 SubmitDryRunResponse (com.twitter.heron.scheduler.dryrun.SubmitDryRunResponse)1 File (java.io.File)1