use of com.twitter.heron.packing.builder.PackingPlanBuilder in project heron by twitter.
the class ResourceCompliantRRPacking method newPackingPlanBuilder.
private PackingPlanBuilder newPackingPlanBuilder(PackingPlan existingPackingPlan) {
List<TopologyAPI.Config.KeyValue> topologyConfig = topology.getTopologyConfig().getKvsList();
double defaultCpu = this.defaultInstanceResources.getCpu() * DEFAULT_NUMBER_INSTANCES_PER_CONTAINER;
ByteAmount defaultRam = this.defaultInstanceResources.getRam().multiply(DEFAULT_NUMBER_INSTANCES_PER_CONTAINER);
ByteAmount defaultDisk = this.defaultInstanceResources.getDisk().multiply(DEFAULT_NUMBER_INSTANCES_PER_CONTAINER);
int paddingPercentage = TopologyUtils.getConfigWithDefault(topologyConfig, TOPOLOGY_CONTAINER_PADDING_PERCENTAGE, DEFAULT_CONTAINER_PADDING_PERCENTAGE);
Resource maxContainerResources = new Resource(TopologyUtils.getConfigWithDefault(topologyConfig, TOPOLOGY_CONTAINER_CPU_REQUESTED, (double) Math.round(PackingUtils.increaseBy(defaultCpu, paddingPercentage))), TopologyUtils.getConfigWithDefault(topologyConfig, TOPOLOGY_CONTAINER_RAM_REQUESTED, defaultRam.increaseBy(paddingPercentage)), TopologyUtils.getConfigWithDefault(topologyConfig, TOPOLOGY_CONTAINER_DISK_REQUESTED, defaultDisk.increaseBy(paddingPercentage)));
return new PackingPlanBuilder(topology.getId(), existingPackingPlan).setMaxContainerResource(maxContainerResources).setDefaultInstanceResource(defaultInstanceResources).setRequestedContainerPadding(paddingPercentage).setRequestedComponentRam(TopologyUtils.getComponentRamMapConfig(topology));
}
use of com.twitter.heron.packing.builder.PackingPlanBuilder in project incubator-heron by apache.
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 (ResourceExceededException 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));
increaseNumContainers(1);
resetToFirstContainer();
}
}
}
use of com.twitter.heron.packing.builder.PackingPlanBuilder in project incubator-heron by apache.
the class ResourceCompliantRRPacking method newPackingPlanBuilder.
private PackingPlanBuilder newPackingPlanBuilder(PackingPlan existingPackingPlan) {
List<TopologyAPI.Config.KeyValue> topologyConfig = topology.getTopologyConfig().getKvsList();
double defaultCpu = this.defaultInstanceResources.getCpu() * DEFAULT_NUMBER_INSTANCES_PER_CONTAINER;
ByteAmount defaultRam = this.defaultInstanceResources.getRam().multiply(DEFAULT_NUMBER_INSTANCES_PER_CONTAINER);
ByteAmount defaultDisk = this.defaultInstanceResources.getDisk().multiply(DEFAULT_NUMBER_INSTANCES_PER_CONTAINER);
int paddingPercentage = TopologyUtils.getConfigWithDefault(topologyConfig, TOPOLOGY_CONTAINER_PADDING_PERCENTAGE, DEFAULT_CONTAINER_PADDING_PERCENTAGE);
Resource maxContainerResources = new Resource(TopologyUtils.getConfigWithDefault(topologyConfig, TOPOLOGY_CONTAINER_CPU_REQUESTED, (double) Math.round(PackingUtils.increaseBy(defaultCpu, paddingPercentage))), TopologyUtils.getConfigWithDefault(topologyConfig, TOPOLOGY_CONTAINER_RAM_REQUESTED, defaultRam.increaseBy(paddingPercentage)), TopologyUtils.getConfigWithDefault(topologyConfig, TOPOLOGY_CONTAINER_DISK_REQUESTED, defaultDisk.increaseBy(paddingPercentage)));
LOG.info(String.format("ResourceCompliantRRPacking newPackingPlanBuilder. " + "CPU max: %f, RAMmaxMax: %s, DISK max: %s, Padding percentage: %d.", maxContainerResources.getCpu(), maxContainerResources.getRam().toString(), maxContainerResources.getDisk().toString(), paddingPercentage));
return new PackingPlanBuilder(topology.getId(), existingPackingPlan).setMaxContainerResource(maxContainerResources).setDefaultInstanceResource(defaultInstanceResources).setRequestedContainerPadding(paddingPercentage).setRequestedComponentRam(TopologyUtils.getComponentRamMapConfig(topology));
}
Aggregations