Search in sources :

Example 21 with ApplicationSLA

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;
}
Also used : ApplicationSLA(com.netflix.titus.api.model.ApplicationSLA)

Example 22 with ApplicationSLA

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();
}
Also used : Pattern(java.util.regex.Pattern) ApplicationSLA(com.netflix.titus.api.model.ApplicationSLA) Pair(com.netflix.titus.common.util.tuple.Pair)

Example 23 with ApplicationSLA

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);
}
Also used : ResourceConsumptionEvent(com.netflix.titus.master.service.management.ResourceConsumptionEvents.ResourceConsumptionEvent) CollectionsExt(com.netflix.titus.common.util.CollectionsExt) Set(java.util.Set) HashMap(java.util.HashMap) Tier(com.netflix.titus.api.model.Tier) ResourceDimensions(com.netflix.titus.master.model.ResourceDimensions) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ApplicationSlaSample(com.netflix.titus.testkit.data.core.ApplicationSlaSample) List(java.util.List) ResourceConsumption(com.netflix.titus.master.service.management.ResourceConsumption) Map(java.util.Map) Optional(java.util.Optional) Preconditions(com.google.common.base.Preconditions) ApplicationSLA(com.netflix.titus.api.model.ApplicationSLA) CompositeResourceConsumption(com.netflix.titus.master.service.management.CompositeResourceConsumption) ConsumptionLevel(com.netflix.titus.master.service.management.ResourceConsumption.ConsumptionLevel) Collections(java.util.Collections) ResourceDimension(com.netflix.titus.api.model.ResourceDimension) ResourceConsumptions(com.netflix.titus.master.service.management.ResourceConsumptions) HashMap(java.util.HashMap) Tier(com.netflix.titus.api.model.Tier) CompositeResourceConsumption(com.netflix.titus.master.service.management.CompositeResourceConsumption) ResourceConsumption(com.netflix.titus.master.service.management.ResourceConsumption) CompositeResourceConsumption(com.netflix.titus.master.service.management.CompositeResourceConsumption) ApplicationSLA(com.netflix.titus.api.model.ApplicationSLA) ArrayList(java.util.ArrayList) List(java.util.List) ResourceDimension(com.netflix.titus.api.model.ResourceDimension) HashSet(java.util.HashSet)

Example 24 with ApplicationSLA

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());
}
Also used : ApplicationSLA(com.netflix.titus.api.model.ApplicationSLA) Test(org.junit.Test)

Example 25 with ApplicationSLA

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();
}
Also used : ApplicationSLA(com.netflix.titus.api.model.ApplicationSLA) Test(org.junit.Test)

Aggregations

ApplicationSLA (com.netflix.titus.api.model.ApplicationSLA)28 Test (org.junit.Test)9 List (java.util.List)5 NotFoundException (com.netflix.titus.api.store.v2.exception.NotFoundException)4 Pair (com.netflix.titus.common.util.tuple.Pair)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 Job (com.netflix.titus.api.jobmanager.model.job.Job)3 Task (com.netflix.titus.api.jobmanager.model.job.Task)3 CollectionsExt (com.netflix.titus.common.util.CollectionsExt)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 TaskAttributes (com.netflix.titus.api.jobmanager.TaskAttributes)2 JobDescriptor (com.netflix.titus.api.jobmanager.model.job.JobDescriptor)2 TaskState (com.netflix.titus.api.jobmanager.model.job.TaskState)2 BatchJobExt (com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt)2 ResourceDimension (com.netflix.titus.api.model.ResourceDimension)2 Tier (com.netflix.titus.api.model.Tier)2 ApplicationSlaStore (com.netflix.titus.api.store.v2.ApplicationSlaStore)2 TitusChangeAction (com.netflix.titus.master.jobmanager.service.common.action.TitusChangeAction)2