use of com.netflix.titus.api.model.Tier in project titus-control-plane by Netflix.
the class JobAndTaskMetrics method updateTaskMetrics.
private void updateTaskMetrics(TaskUpdateEvent event) {
Job<?> job = event.getCurrentJob();
Task task = event.getCurrentTask();
Pair<Tier, String> assignment = JobManagerUtil.getTierAssignment(job, applicationSlaManagementService);
registry.counter(TASK_STATE_CHANGE_METRIC_NAME, "tier", assignment.getLeft().name(), "capacityGroup", assignment.getRight(), "applicationName", job.getJobDescriptor().getApplicationName(), "state", task.getStatus().getState().name(), "kubeScheduler", "true").increment();
}
use of com.netflix.titus.api.model.Tier 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);
}
use of com.netflix.titus.api.model.Tier in project titus-control-plane by Netflix.
the class Representation2ModelConvertions method asCoreEntity.
public static ApplicationSLA asCoreEntity(ApplicationSlaRepresentation representation) {
ResourceDimension resourceDimension = ResourceDimension.newBuilder().withCpus(representation.getInstanceCPU()).withMemoryMB(representation.getInstanceMemoryMB()).withDiskMB(representation.getInstanceDiskMB()).withNetworkMbs(representation.getInstanceNetworkMbs()).withGpu(representation.getInstanceGPU()).build();
Tier tier;
if (representation.getTier() != null) {
tier = Tier.valueOf(representation.getTier().name());
} else {
tier = Tier.Flex;
}
return ApplicationSLA.newBuilder().withAppName(representation.getAppName()).withTier(tier).withResourceDimension(resourceDimension).withInstanceCount(representation.getInstanceCount()).withSchedulerName(representation.getSchedulerName()).withResourcePool(representation.getResourcePool()).build();
}
use of com.netflix.titus.api.model.Tier in project titus-control-plane by Netflix.
the class ConsumptionModelGenerator method getEvaluation.
DefaultResourceConsumptionService.ConsumptionEvaluationResult getEvaluation() {
Map<String, CompositeResourceConsumption> groupConsumptionMap = new HashMap<>();
Set<String> definedCapacityGroups = new HashSet<>(capacityGroupMap.keySet());
// Used capacity groups
Set<String> capacityGroupNames = actualConsumptionByGroupAndApp.keySet();
for (String capacityGroupName : capacityGroupNames) {
List<ResourceConsumption> appConsumptions = buildApplicationConsumptions(capacityGroupName);
CompositeResourceConsumption groupConsumption = ResourceConsumptions.aggregate(capacityGroupName, ConsumptionLevel.CapacityGroup, appConsumptions, capacityGroupLimit(capacityGroupMap.getOrDefault(capacityGroupName, DEFAULT_SLA)));
groupConsumptionMap.put(capacityGroupName, groupConsumption);
}
// Unused capacity groups
CollectionsExt.copyAndRemove(definedCapacityGroups, capacityGroupNames).forEach(capacityGroup -> {
ApplicationSLA sla = capacityGroupMap.getOrDefault(capacityGroup, DEFAULT_SLA);
ResourceDimension limit = capacityGroupLimit(sla);
groupConsumptionMap.put(capacityGroup, new CompositeResourceConsumption(capacityGroup, ConsumptionLevel.CapacityGroup, ResourceDimension.empty(), ResourceDimension.empty(), limit, Collections.emptyMap(), Collections.emptyMap(), false));
});
// Undefined capacity groups
Set<String> undefinedCapacityGroups = CollectionsExt.copyAndRemove(capacityGroupNames, definedCapacityGroups);
// Tier consumption
Map<Tier, List<CompositeResourceConsumption>> tierCapacityGroups = groupConsumptionMap.values().stream().collect(Collectors.groupingBy(rc -> {
ApplicationSLA sla = capacityGroupMap.get(rc.getConsumerName());
if (sla == null) {
sla = capacityGroupMap.get(DEFAULT_SLA.getAppName());
}
return sla.getTier();
}));
Map<String, CompositeResourceConsumption> tierConsumptions = new HashMap<>();
tierCapacityGroups.forEach((tier, consumptions) -> tierConsumptions.put(tier.name(), ResourceConsumptions.aggregate(tier.name(), ConsumptionLevel.Tier, consumptions)));
// System consumption
CompositeResourceConsumption systemConsumption = ResourceConsumptions.aggregate(ResourceConsumption.SYSTEM_CONSUMER, ConsumptionLevel.System, tierConsumptions.values());
return new DefaultResourceConsumptionService.ConsumptionEvaluationResult(definedCapacityGroups, undefinedCapacityGroups, systemConsumption);
}
Aggregations