Search in sources :

Example 1 with EvictionQuota

use of com.netflix.titus.api.eviction.model.EvictionQuota in project titus-control-plane by Netflix.

the class JobQuotaController method getMinSubQuota.

private EvictionQuota getMinSubQuota(Reference reference) {
    EvictionQuota minTrackers = getMinSubQuota(quotaTrackers, reference);
    EvictionQuota minControllers = getMinSubQuota(quotaControllers, reference);
    return minTrackers.getQuota() <= minControllers.getQuota() ? minTrackers : minControllers;
}
Also used : EvictionQuota(com.netflix.titus.api.eviction.model.EvictionQuota)

Example 2 with EvictionQuota

use of com.netflix.titus.api.eviction.model.EvictionQuota in project titus-control-plane by Netflix.

the class JobQuotaController method consume.

@Override
public ConsumptionResult consume(String taskId) {
    if (isLegacy()) {
        return LEGACY;
    }
    Reference taskReference = Reference.task(taskId);
    StringBuilder rejectionResponseBuilder = new StringBuilder("MissingQuotas[");
    // Check quota trackers first
    boolean noQuota = false;
    for (QuotaTracker tracker : quotaTrackers) {
        EvictionQuota quotaStatus = tracker.getQuota(taskReference);
        if (quotaStatus.getQuota() <= 0) {
            noQuota = true;
            rejectionResponseBuilder.append(tracker.getClass().getSimpleName()).append('=').append(quotaStatus.getMessage()).append(", ");
        }
    }
    if (noQuota) {
        rejectionResponseBuilder.setLength(rejectionResponseBuilder.length() - 2);
        return ConsumptionResult.rejected(rejectionResponseBuilder.append(']').toString());
    }
    // Now controllers
    for (int i = 0; i < quotaControllers.size(); i++) {
        QuotaController<Job<?>> controller = quotaControllers.get(i);
        ConsumptionResult result = controller.consume(taskId);
        if (!result.isApproved()) {
            for (int j = 0; j < i; j++) {
                quotaControllers.get(j).giveBackConsumedQuota(taskId);
            }
            rejectionResponseBuilder.append(controller.getClass().getSimpleName()).append('=').append(result.getRejectionReason().orElse("no quota"));
            return ConsumptionResult.rejected(rejectionResponseBuilder.append(']').toString());
        }
    }
    return ConsumptionResult.approved();
}
Also used : TimeWindowQuotaTracker(com.netflix.titus.master.eviction.service.quota.TimeWindowQuotaTracker) QuotaTracker(com.netflix.titus.master.eviction.service.quota.QuotaTracker) EvictionQuota(com.netflix.titus.api.eviction.model.EvictionQuota) ConsumptionResult(com.netflix.titus.master.eviction.service.quota.ConsumptionResult) Reference(com.netflix.titus.api.model.reference.Reference) Job(com.netflix.titus.api.jobmanager.model.job.Job)

Example 3 with EvictionQuota

use of com.netflix.titus.api.eviction.model.EvictionQuota in project titus-control-plane by Netflix.

the class TaskRelocationLimitController method getTaskQuota.

private EvictionQuota getTaskQuota(Reference taskReference) {
    String taskId = taskReference.getName();
    EvictionQuota.Builder quotaBuilder = EvictionQuota.newBuilder().withReference(taskReference);
    Optional<Pair<Job<?>, Task>> jobTaskOpt = jobOperations.findTaskById(taskId);
    if (!jobTaskOpt.isPresent()) {
        return quotaBuilder.withQuota(0).withMessage("Task not found").build();
    }
    Task task = jobTaskOpt.get().getRight();
    int counter = task.getEvictionResubmitNumber();
    if (counter < perTaskLimit) {
        return quotaBuilder.withQuota(1).withMessage("Per task limit is %s, and restart count is %s", perTaskLimit, counter).build();
    }
    return quotaBuilder.withQuota(0).withMessage(taskLimitExceeded.getRejectionReason().get()).build();
}
Also used : EvictionQuota(com.netflix.titus.api.eviction.model.EvictionQuota) Task(com.netflix.titus.api.jobmanager.model.job.Task) Pair(com.netflix.titus.common.util.tuple.Pair)

Example 4 with EvictionQuota

use of com.netflix.titus.api.eviction.model.EvictionQuota in project titus-control-plane by Netflix.

the class TaskRelocationLimitController method getJobQuota.

private EvictionQuota getJobQuota(Reference jobReference) {
    EvictionQuota.Builder quotaBuilder = EvictionQuota.newBuilder().withReference(jobReference);
    List<Task> tasks;
    try {
        tasks = jobOperations.getTasks(job.getId());
    } catch (JobManagerException e) {
        return quotaBuilder.withQuota(0).withMessage("Internal error: %s", e.getMessage()).build();
    }
    int quota = 0;
    for (Task task : tasks) {
        if (task.getEvictionResubmitNumber() < perTaskLimit) {
            quota++;
        }
    }
    return quota > 0 ? quotaBuilder.withQuota(quota).withMessage("Per task limit is %s", perTaskLimit).build() : quotaBuilder.withQuota(0).withMessage("Each task of the job reached its maximum eviction limit %s", perTaskLimit).build();
}
Also used : EvictionQuota(com.netflix.titus.api.eviction.model.EvictionQuota) Task(com.netflix.titus.api.jobmanager.model.job.Task) JobManagerException(com.netflix.titus.api.jobmanager.service.JobManagerException)

Aggregations

EvictionQuota (com.netflix.titus.api.eviction.model.EvictionQuota)4 Task (com.netflix.titus.api.jobmanager.model.job.Task)2 Job (com.netflix.titus.api.jobmanager.model.job.Job)1 JobManagerException (com.netflix.titus.api.jobmanager.service.JobManagerException)1 Reference (com.netflix.titus.api.model.reference.Reference)1 Pair (com.netflix.titus.common.util.tuple.Pair)1 ConsumptionResult (com.netflix.titus.master.eviction.service.quota.ConsumptionResult)1 QuotaTracker (com.netflix.titus.master.eviction.service.quota.QuotaTracker)1 TimeWindowQuotaTracker (com.netflix.titus.master.eviction.service.quota.TimeWindowQuotaTracker)1