Search in sources :

Example 26 with PackingPlan

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

the class SubmitJsonDryRunRenderer method render.

public String render() {
    String topologyName = response.getTopology().getName();
    String packingClassName = Context.packingClass(response.getConfig());
    PackingPlan packingPlan = response.getPackingPlan();
    try {
        return formatter.renderPackingPlan(topologyName, packingClassName, packingPlan);
    } catch (JsonProcessingException e) {
        return "ERROR: " + e.getMessage();
    }
}
Also used : PackingPlan(org.apache.heron.spi.packing.PackingPlan) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 27 with PackingPlan

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

the class RuntimeManagerRunner method sendUpdateRequest.

void sendUpdateRequest(TopologyAPI.Topology topology, Map<String, Integer> changeRequests, PackingPlans.PackingPlan currentPlan, PackingPlans.PackingPlan proposedPlan) {
    if (Context.dryRun(config)) {
        PackingPlanProtoDeserializer deserializer = new PackingPlanProtoDeserializer();
        PackingPlan oldPlan = deserializer.fromProto(currentPlan);
        PackingPlan newPlan = deserializer.fromProto(proposedPlan);
        throw new UpdateDryRunResponse(topology, config, newPlan, oldPlan, changeRequests);
    }
    Scheduler.UpdateTopologyRequest updateTopologyRequest = Scheduler.UpdateTopologyRequest.newBuilder().setCurrentPackingPlan(currentPlan).setProposedPackingPlan(proposedPlan).build();
    LOG.fine("Sending Updating topology request: " + updateTopologyRequest);
    if (!schedulerClient.updateTopology(updateTopologyRequest)) {
        throw new TopologyRuntimeManagementException("Failed to update topology with Scheduler, updateTopologyRequest=" + updateTopologyRequest + "The topology can be in a strange stage. " + "Please check carefully or redeploy the topology !!");
    }
}
Also used : PackingPlanProtoDeserializer(org.apache.heron.spi.packing.PackingPlanProtoDeserializer) UpdateDryRunResponse(org.apache.heron.scheduler.dryrun.UpdateDryRunResponse) Scheduler(org.apache.heron.proto.scheduler.Scheduler) PackingPlan(org.apache.heron.spi.packing.PackingPlan)

Example 28 with PackingPlan

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

the class RoundRobinPackingTest method testContainerRequestedResources.

/**
 * Test the scenario container level resource config are set
 */
@Test
public void testContainerRequestedResources() throws Exception {
    // Explicit set resources for container
    ByteAmount containerRam = ByteAmount.fromGigabytes(10);
    ByteAmount containerDisk = ByteAmount.fromGigabytes(20);
    double containerCpu = 30;
    Resource containerResource = new Resource(containerCpu, containerRam, containerDisk);
    topologyConfig.setContainerRamRequested(containerRam);
    topologyConfig.setContainerDiskRequested(containerDisk);
    topologyConfig.setContainerCpuRequested(containerCpu);
    topology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
    PackingPlan packingPlan = doPackingTestWithPartialResource(topology, Optional.empty(), Optional.empty(), boltParallelism, Optional.empty(), Optional.empty(), spoutParallelism, numContainers, getDefaultPadding(), containerResource);
    for (PackingPlan.ContainerPlan containerPlan : packingPlan.getContainers()) {
        // All instances' resource requirement should be equal
        // So the size of set should be 1
        Set<Resource> differentResources = new HashSet<>();
        for (PackingPlan.InstancePlan instancePlan : containerPlan.getInstances()) {
            differentResources.add(instancePlan.getResource());
        }
        Assert.assertEquals(1, differentResources.size());
        int instancesCount = containerPlan.getInstances().size();
        Assert.assertEquals(containerRam.minus(RoundRobinPacking.DEFAULT_RAM_PADDING_PER_CONTAINER).divide(instancesCount), differentResources.iterator().next().getRam());
        Assert.assertEquals((containerCpu - RoundRobinPacking.DEFAULT_CPU_PADDING_PER_CONTAINER) / instancesCount, differentResources.iterator().next().getCpu(), DELTA);
    }
}
Also used : ByteAmount(org.apache.heron.common.basics.ByteAmount) PackingPlan(org.apache.heron.spi.packing.PackingPlan) Resource(org.apache.heron.spi.packing.Resource) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 29 with PackingPlan

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

the class RoundRobinPackingTest method testRepackingWithFewerTotalInstances.

/**
 * test re-packing with fewer total instances
 */
@Test
public void testRepackingWithFewerTotalInstances() throws Exception {
    int componentParallelism = 4;
    boltParallelism = componentParallelism;
    spoutParallelism = componentParallelism;
    topology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
    PackingPlan packingPlan = doPackingTestWithPartialResource(topology, Optional.empty(), Optional.empty(), boltParallelism, Optional.empty(), Optional.empty(), spoutParallelism, numContainers, getDefaultPadding(), getDefaultUnspecifiedContainerResource(boltParallelism + spoutParallelism, numContainers, getDefaultPadding()));
    Map<String, Integer> componentChanges = new HashMap<>();
    componentChanges.put(SPOUT_NAME, -2);
    componentChanges.put(BOLT_NAME, -2);
    doScalingTestWithPartialResource(topology, packingPlan, componentChanges, Optional.empty(), Optional.empty(), boltParallelism, Optional.empty(), Optional.empty(), spoutParallelism, numContainers - 1, getDefaultPadding(), getDefaultUnspecifiedContainerResource(boltParallelism + spoutParallelism, numContainers, getDefaultPadding()));
}
Also used : HashMap(java.util.HashMap) PackingPlan(org.apache.heron.spi.packing.PackingPlan) Test(org.junit.Test)

Example 30 with PackingPlan

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

the class PackingTestUtils method testProtoPackingPlan.

public static PackingPlans.PackingPlan testProtoPackingPlan(String topologyName, IPacking packing) {
    PackingPlan plan = testPackingPlan(topologyName, packing);
    PackingPlanProtoSerializer serializer = new PackingPlanProtoSerializer();
    return serializer.toProto(plan);
}
Also used : PackingPlanProtoSerializer(org.apache.heron.spi.packing.PackingPlanProtoSerializer) PackingPlan(org.apache.heron.spi.packing.PackingPlan)

Aggregations

PackingPlan (org.apache.heron.spi.packing.PackingPlan)83 Test (org.junit.Test)43 HashSet (java.util.HashSet)32 Resource (org.apache.heron.spi.packing.Resource)18 Config (org.apache.heron.spi.common.Config)15 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)14 ByteAmount (org.apache.heron.common.basics.ByteAmount)13 HashMap (java.util.HashMap)10 SchedulerStateManagerAdaptor (org.apache.heron.spi.statemgr.SchedulerStateManagerAdaptor)9 TopologyAPI (org.apache.heron.api.generated.TopologyAPI)8 RoundRobinPacking (org.apache.heron.packing.roundrobin.RoundRobinPacking)7 InstanceId (org.apache.heron.spi.packing.InstanceId)7 Pair (org.apache.heron.common.basics.Pair)6 PackingPlans (org.apache.heron.proto.system.PackingPlans)6 PackingPlanProtoDeserializer (org.apache.heron.spi.packing.PackingPlanProtoDeserializer)6 ContainerPlan (org.apache.heron.spi.packing.PackingPlan.ContainerPlan)5 ArrayList (java.util.ArrayList)4 PackingPlanProtoSerializer (org.apache.heron.spi.packing.PackingPlanProtoSerializer)4 EvaluatorRequest (org.apache.reef.driver.evaluator.EvaluatorRequest)4 Before (org.junit.Before)3