Search in sources :

Example 1 with HomogeneityScorer

use of com.twitter.heron.packing.builder.HomogeneityScorer 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) {
    ArrayList<RamRequirement> ramRequirements = getSortedRAMInstances(componentsToScaleDown.keySet());
    InstanceCountScorer instanceCountScorer = new InstanceCountScorer();
    ContainerIdScorer containerIdScorer = new ContainerIdScorer(false);
    for (RamRequirement ramRequirement : ramRequirements) {
        String componentName = ramRequirement.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 : RamRequirement(com.twitter.heron.packing.RamRequirement) ArrayList(java.util.ArrayList) InstanceCountScorer(com.twitter.heron.packing.builder.InstanceCountScorer) ContainerIdScorer(com.twitter.heron.packing.builder.ContainerIdScorer) Scorer(com.twitter.heron.packing.builder.Scorer) HomogeneityScorer(com.twitter.heron.packing.builder.HomogeneityScorer) HomogeneityScorer(com.twitter.heron.packing.builder.HomogeneityScorer) InstanceCountScorer(com.twitter.heron.packing.builder.InstanceCountScorer) ContainerIdScorer(com.twitter.heron.packing.builder.ContainerIdScorer)

Example 2 with HomogeneityScorer

use of com.twitter.heron.packing.builder.HomogeneityScorer in project incubator-heron by apache.

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) InstanceCountScorer(com.twitter.heron.packing.builder.InstanceCountScorer) ContainerIdScorer(com.twitter.heron.packing.builder.ContainerIdScorer) Scorer(com.twitter.heron.packing.builder.Scorer) HomogeneityScorer(com.twitter.heron.packing.builder.HomogeneityScorer) HomogeneityScorer(com.twitter.heron.packing.builder.HomogeneityScorer) InstanceCountScorer(com.twitter.heron.packing.builder.InstanceCountScorer) ContainerIdScorer(com.twitter.heron.packing.builder.ContainerIdScorer)

Example 3 with HomogeneityScorer

use of com.twitter.heron.packing.builder.HomogeneityScorer in project incubator-heron by apache.

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) {
    ArrayList<RamRequirement> ramRequirements = getSortedRAMInstances(componentsToScaleDown.keySet());
    InstanceCountScorer instanceCountScorer = new InstanceCountScorer();
    ContainerIdScorer containerIdScorer = new ContainerIdScorer(false);
    for (RamRequirement ramRequirement : ramRequirements) {
        String componentName = ramRequirement.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 : RamRequirement(com.twitter.heron.packing.RamRequirement) ArrayList(java.util.ArrayList) InstanceCountScorer(com.twitter.heron.packing.builder.InstanceCountScorer) ContainerIdScorer(com.twitter.heron.packing.builder.ContainerIdScorer) Scorer(com.twitter.heron.packing.builder.Scorer) HomogeneityScorer(com.twitter.heron.packing.builder.HomogeneityScorer) HomogeneityScorer(com.twitter.heron.packing.builder.HomogeneityScorer) InstanceCountScorer(com.twitter.heron.packing.builder.InstanceCountScorer) ContainerIdScorer(com.twitter.heron.packing.builder.ContainerIdScorer)

Example 4 with HomogeneityScorer

use of com.twitter.heron.packing.builder.HomogeneityScorer 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) InstanceCountScorer(com.twitter.heron.packing.builder.InstanceCountScorer) ContainerIdScorer(com.twitter.heron.packing.builder.ContainerIdScorer) Scorer(com.twitter.heron.packing.builder.Scorer) HomogeneityScorer(com.twitter.heron.packing.builder.HomogeneityScorer) HomogeneityScorer(com.twitter.heron.packing.builder.HomogeneityScorer) InstanceCountScorer(com.twitter.heron.packing.builder.InstanceCountScorer) ContainerIdScorer(com.twitter.heron.packing.builder.ContainerIdScorer)

Aggregations

ContainerIdScorer (com.twitter.heron.packing.builder.ContainerIdScorer)4 HomogeneityScorer (com.twitter.heron.packing.builder.HomogeneityScorer)4 InstanceCountScorer (com.twitter.heron.packing.builder.InstanceCountScorer)4 Scorer (com.twitter.heron.packing.builder.Scorer)4 ArrayList (java.util.ArrayList)4 RamRequirement (com.twitter.heron.packing.RamRequirement)2