use of com.netflix.titus.api.model.ApplicationSLA in project titus-control-plane by Netflix.
the class DefaultTaintTolerationFactory method resolveTierToleration.
private V1Toleration resolveTierToleration(Job<?> job) {
String capacityGroupName = JobFunctions.getEffectiveCapacityGroup(job);
ApplicationSLA capacityGroup = capacityManagement.findApplicationSLA(capacityGroupName).orElse(null);
if (capacityGroup == null) {
return Tolerations.TOLERATION_TIER_FLEX;
}
return capacityGroup.getTier() == Tier.Critical ? Tolerations.TOLERATION_TIER_CRITICAL : Tolerations.TOLERATION_TIER_FLEX;
}
use of com.netflix.titus.api.model.ApplicationSLA in project titus-control-plane by Netflix.
the class CapacityGroupPodResourcePoolResolver method resolve.
@Override
public List<ResourcePoolAssignment> resolve(Job<?> job, Task task) {
ApplicationSLA capacityGroup = JobManagerUtil.getCapacityGroupDescriptor(job.getJobDescriptor(), capacityGroupService);
if (capacityGroup == null) {
return Collections.emptyList();
}
List<Pair<String, Pattern>> currentMappers = getCurrentMappers();
for (Pair<String, Pattern> next : currentMappers) {
Pattern pattern = next.getRight();
if (pattern.matcher(capacityGroup.getAppName()).matches()) {
return Collections.singletonList(ResourcePoolAssignment.newBuilder().withResourcePoolName(next.getLeft()).withRule(String.format("Capacity group %s matches %s", capacityGroup.getAppName(), pattern.toString())).build());
}
}
return Collections.emptyList();
}
use of com.netflix.titus.api.model.ApplicationSLA 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);
}
use of com.netflix.titus.api.model.ApplicationSLA in project titus-control-plane by Netflix.
the class DefaultApplicationSlaManagementServiceTest method testGetApplicationByName.
@Test
public void testGetApplicationByName() throws Exception {
ApplicationSLA myApp = ApplicationSlaSample.CriticalSmall.build();
when(storage.findByName(myApp.getAppName())).thenReturn(Observable.just(myApp));
ApplicationSLA result = slaManagementService.getApplicationSLA(myApp.getAppName());
assertThat(result.getAppName()).isEqualTo(myApp.getAppName());
assertThat(result.getSchedulerName()).isEqualTo(myApp.getSchedulerName());
}
use of com.netflix.titus.api.model.ApplicationSLA in project titus-control-plane by Netflix.
the class DefaultApplicationSlaManagementServiceTest method testFindApplicationByName.
@Test
public void testFindApplicationByName() {
ApplicationSLA myApp = ApplicationSlaSample.CriticalSmall.build();
when(storage.findByName(myApp.getAppName())).thenReturn(Observable.just(myApp));
Optional<ApplicationSLA> existing = slaManagementService.findApplicationSLA(myApp.getAppName());
assertThat(existing).hasValueSatisfying(v -> assertThat(v.getAppName()).isEqualTo(myApp.getAppName()));
Optional<ApplicationSLA> absent = slaManagementService.findApplicationSLA("absent");
assertThat(absent).isEmpty();
}
Aggregations