Search in sources :

Example 1 with InstanceCountScorer

use of org.apache.heron.packing.builder.InstanceCountScorer in project heron by twitter.

the class ResourceCompliantRRPacking method removeRRInstance.

/**
 * Remove an instance of a particular component from the containers
 */
private void removeRRInstance(PackingPlanBuilder packingPlanBuilder, String componentName) throws RuntimeException {
    List<Scorer<Container>> scorers = new ArrayList<>();
    // all-same-component containers first
    scorers.add(new HomogeneityScorer(componentName, true));
    // then fewest instances
    scorers.add(new InstanceCountScorer());
    // then most homogeneous
    scorers.add(new HomogeneityScorer(componentName, false));
    // then highest container id
    scorers.add(new ContainerIdScorer(false));
    this.containerId = nextContainerId(packingPlanBuilder.removeInstance(scorers, componentName));
}
Also used : ArrayList(java.util.ArrayList) Scorer(org.apache.heron.packing.builder.Scorer) InstanceCountScorer(org.apache.heron.packing.builder.InstanceCountScorer) HomogeneityScorer(org.apache.heron.packing.builder.HomogeneityScorer) ContainerIdScorer(org.apache.heron.packing.builder.ContainerIdScorer) HomogeneityScorer(org.apache.heron.packing.builder.HomogeneityScorer) InstanceCountScorer(org.apache.heron.packing.builder.InstanceCountScorer) ContainerIdScorer(org.apache.heron.packing.builder.ContainerIdScorer)

Example 2 with InstanceCountScorer

use of org.apache.heron.packing.builder.InstanceCountScorer in project heron by twitter.

the class FirstFitDecreasingPacking method removeInstancesFromContainers.

/**
 * Removes instances from containers during scaling down
 *
 * @param packingPlanBuilder existing packing plan
 * @param componentsToScaleDown scale down factor for the components.
 */
private void removeInstancesFromContainers(PackingPlanBuilder packingPlanBuilder, Map<String, Integer> componentsToScaleDown) {
    List<ResourceRequirement> resourceRequirements = getSortedInstances(componentsToScaleDown.keySet());
    InstanceCountScorer instanceCountScorer = new InstanceCountScorer();
    ContainerIdScorer containerIdScorer = new ContainerIdScorer(false);
    for (ResourceRequirement resourceRequirement : resourceRequirements) {
        String componentName = resourceRequirement.getComponentName();
        int numInstancesToRemove = -componentsToScaleDown.get(componentName);
        List<Scorer<Container>> scorers = new ArrayList<>();
        // all-same-component containers
        scorers.add(new HomogeneityScorer(componentName, true));
        // then fewest instances
        scorers.add(instanceCountScorer);
        // then most homogeneous
        scorers.add(new HomogeneityScorer(componentName, false));
        // then highest container id
        scorers.add(containerIdScorer);
        for (int j = 0; j < numInstancesToRemove; j++) {
            packingPlanBuilder.removeInstance(scorers, componentName);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Scorer(org.apache.heron.packing.builder.Scorer) InstanceCountScorer(org.apache.heron.packing.builder.InstanceCountScorer) ContainerIdScorer(org.apache.heron.packing.builder.ContainerIdScorer) HomogeneityScorer(org.apache.heron.packing.builder.HomogeneityScorer) ResourceRequirement(org.apache.heron.packing.builder.ResourceRequirement) HomogeneityScorer(org.apache.heron.packing.builder.HomogeneityScorer) MinRamConstraint(org.apache.heron.packing.constraints.MinRamConstraint) ResourceConstraint(org.apache.heron.packing.constraints.ResourceConstraint) InstanceDensityConstraint(org.apache.heron.packing.constraints.InstanceDensityConstraint) MinCpuConstraint(org.apache.heron.packing.constraints.MinCpuConstraint) InstanceCountScorer(org.apache.heron.packing.builder.InstanceCountScorer) ContainerIdScorer(org.apache.heron.packing.builder.ContainerIdScorer)

Aggregations

ArrayList (java.util.ArrayList)2 ContainerIdScorer (org.apache.heron.packing.builder.ContainerIdScorer)2 HomogeneityScorer (org.apache.heron.packing.builder.HomogeneityScorer)2 InstanceCountScorer (org.apache.heron.packing.builder.InstanceCountScorer)2 Scorer (org.apache.heron.packing.builder.Scorer)2 ResourceRequirement (org.apache.heron.packing.builder.ResourceRequirement)1 InstanceDensityConstraint (org.apache.heron.packing.constraints.InstanceDensityConstraint)1 MinCpuConstraint (org.apache.heron.packing.constraints.MinCpuConstraint)1 MinRamConstraint (org.apache.heron.packing.constraints.MinRamConstraint)1 ResourceConstraint (org.apache.heron.packing.constraints.ResourceConstraint)1