Search in sources :

Example 41 with Pair

use of com.netflix.titus.common.util.tuple.Pair 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)

Aggregations

Pair (com.netflix.titus.common.util.tuple.Pair)41 Task (com.netflix.titus.api.jobmanager.model.job.Task)22 List (java.util.List)21 ArrayList (java.util.ArrayList)18 Job (com.netflix.titus.api.jobmanager.model.job.Job)14 Map (java.util.Map)10 Collectors (java.util.stream.Collectors)10 TitusRuntime (com.netflix.titus.common.runtime.TitusRuntime)8 Optional (java.util.Optional)8 Logger (org.slf4j.Logger)8 LoggerFactory (org.slf4j.LoggerFactory)8 TaskState (com.netflix.titus.api.jobmanager.model.job.TaskState)7 HashMap (java.util.HashMap)7 JobFunctions (com.netflix.titus.api.jobmanager.model.job.JobFunctions)6 Collections (java.util.Collections)6 Observable (rx.Observable)6 TaskRelocationPlan (com.netflix.titus.api.relocation.model.TaskRelocationPlan)5 Function (java.util.function.Function)5 PreparedStatement (com.datastax.driver.core.PreparedStatement)4 Session (com.datastax.driver.core.Session)4