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();
}
}
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 !!");
}
}
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);
}
}
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()));
}
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);
}
Aggregations