use of com.twitter.heron.packing.builder.ContainerIdScorer 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);
}
}
}
use of com.twitter.heron.packing.builder.ContainerIdScorer in project heron by twitter.
the class ResourceCompliantRRPacking method flexibleRRpolicy.
/**
* Performs a RR placement. Tries to place the instance on any container with space, starting at
* containerId and cycling through the container set until it can be placed.
*
* @param planBuilder packing plan builder
* @param componentName the component name of the instance that needs to be placed in the container
* @throws ResourceExceededException if there is no room on any container to place the instance
*/
private void flexibleRRpolicy(PackingPlanBuilder planBuilder, String componentName) throws ResourceExceededException {
// If there is not enough space on containerId look at other containers in a RR fashion
// starting from containerId.
ContainerIdScorer scorer = new ContainerIdScorer(this.containerId, this.numContainers);
this.containerId = nextContainerId(planBuilder.addInstance(scorer, componentName));
}
use of com.twitter.heron.packing.builder.ContainerIdScorer 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));
}
Aggregations