Search in sources :

Example 1 with ConstraintViolationException

use of org.apache.heron.packing.exceptions.ConstraintViolationException in project heron by twitter.

the class ResourceCompliantRRPacking method repack.

/**
 * Get a new packing plan given an existing packing plan and component-level changes.
 *
 * @return new packing plan
 */
@Override
public PackingPlan repack(PackingPlan currentPackingPlan, Map<String, Integer> componentChanges) {
    this.numContainers = currentPackingPlan.getContainers().size();
    resetToFirstContainer();
    int additionalContainers = computeNumAdditionalContainers(componentChanges, currentPackingPlan);
    if (additionalContainers > 0) {
        increaseNumContainers(additionalContainers);
        LOG.info(String.format("Allocated %s additional containers for repack bring the number of containers to %s.", additionalContainers, this.numContainers));
    }
    while (true) {
        try {
            PackingPlanBuilder planBuilder = newPackingPlanBuilder(currentPackingPlan);
            planBuilder.updateNumContainers(numContainers);
            planBuilder = getResourceCompliantRRAllocation(planBuilder, componentChanges);
            return planBuilder.build();
        } catch (ConstraintViolationException e) {
            // Not enough containers. Adjust the number of containers.
            LOG.info(String.format("%s Increasing the number of containers to %s and attempting to repack again.", e.getMessage(), this.numContainers + 1));
            retryWithAdditionalContainer();
        }
    }
}
Also used : PackingPlanBuilder(org.apache.heron.packing.builder.PackingPlanBuilder) ConstraintViolationException(org.apache.heron.packing.exceptions.ConstraintViolationException) MinRamConstraint(org.apache.heron.packing.constraints.MinRamConstraint) ResourceConstraint(org.apache.heron.packing.constraints.ResourceConstraint)

Example 2 with ConstraintViolationException

use of org.apache.heron.packing.exceptions.ConstraintViolationException in project heron by twitter.

the class ResourceCompliantRRPacking method pack.

@Override
public PackingPlan pack() {
    while (true) {
        try {
            PackingPlanBuilder planBuilder = newPackingPlanBuilder(null);
            planBuilder.updateNumContainers(numContainers);
            planBuilder = getResourceCompliantRRAllocation(planBuilder);
            return planBuilder.build();
        } catch (ConstraintViolationException e) {
            // Not enough containers. Adjust the number of containers.
            LOG.finest(String.format("%s Increasing the number of containers to %s and attempting to place again.", e.getMessage(), this.numContainers + 1));
            retryWithAdditionalContainer();
        }
    }
}
Also used : PackingPlanBuilder(org.apache.heron.packing.builder.PackingPlanBuilder) ConstraintViolationException(org.apache.heron.packing.exceptions.ConstraintViolationException)

Aggregations

PackingPlanBuilder (org.apache.heron.packing.builder.PackingPlanBuilder)2 ConstraintViolationException (org.apache.heron.packing.exceptions.ConstraintViolationException)2 MinRamConstraint (org.apache.heron.packing.constraints.MinRamConstraint)1 ResourceConstraint (org.apache.heron.packing.constraints.ResourceConstraint)1