use of com.netflix.titus.master.service.management.ResourceConsumption.SYSTEM_CONSUMER in project titus-control-plane by Netflix.
the class ResourceConsumptionEvaluator method buildSystemConsumption.
private CompositeResourceConsumption buildSystemConsumption(Map<String, Map<String, ResourceConsumption>> capacityGroupConsumptionMap) {
// Capacity group level
Map<Tier, List<CompositeResourceConsumption>> tierConsumptions = new HashMap<>();
capacityGroupConsumptionMap.forEach((capacityGroup, appConsumptions) -> {
ApplicationSLA sla = applicationSlaMap.get(capacityGroup);
ResourceDimension allowedConsumption = ResourceDimensions.multiply(sla.getResourceDimension(), sla.getInstanceCount());
ResourceDimension maxConsumption = ResourceConsumptions.addMaxConsumptions(appConsumptions.values());
List<Map<String, Object>> attrsList = appConsumptions.values().stream().map(ResourceConsumption::getAttributes).collect(Collectors.toList());
CompositeResourceConsumption capacityGroupConsumption = new CompositeResourceConsumption(capacityGroup, ConsumptionLevel.CapacityGroup, ResourceConsumptions.addCurrentConsumptions(appConsumptions.values()), maxConsumption, allowedConsumption, ResourceConsumptions.mergeAttributes(attrsList), appConsumptions, !ResourceDimensions.isBigger(allowedConsumption, maxConsumption));
tierConsumptions.computeIfAbsent(sla.getTier(), t -> new ArrayList<>()).add(capacityGroupConsumption);
});
// Tier level
List<CompositeResourceConsumption> aggregatedTierConsumptions = new ArrayList<>();
tierConsumptions.forEach((tier, consumptions) -> aggregatedTierConsumptions.add(ResourceConsumptions.aggregate(tier.name(), ConsumptionLevel.Tier, consumptions)));
// System level
return ResourceConsumptions.aggregate(SYSTEM_CONSUMER, ConsumptionLevel.System, aggregatedTierConsumptions);
}
Aggregations