use of com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudgetPolicy in project titus-control-plane by Netflix.
the class GrpcJobManagementModelConverters method toGrpcDisruptionBudget.
public static com.netflix.titus.grpc.protogen.JobDisruptionBudget toGrpcDisruptionBudget(DisruptionBudget coreDisruptionBudget) {
JobDisruptionBudget.Builder builder = JobDisruptionBudget.newBuilder();
DisruptionBudgetPolicy disruptionBudgetPolicy = coreDisruptionBudget.getDisruptionBudgetPolicy();
if (disruptionBudgetPolicy instanceof SelfManagedDisruptionBudgetPolicy) {
builder.setSelfManaged(JobDisruptionBudget.SelfManaged.newBuilder().setRelocationTimeMs(((SelfManagedDisruptionBudgetPolicy) disruptionBudgetPolicy).getRelocationTimeMs()));
} else if (disruptionBudgetPolicy instanceof AvailabilityPercentageLimitDisruptionBudgetPolicy) {
builder.setAvailabilityPercentageLimit(JobDisruptionBudget.AvailabilityPercentageLimit.newBuilder().setPercentageOfHealthyContainers(((AvailabilityPercentageLimitDisruptionBudgetPolicy) disruptionBudgetPolicy).getPercentageOfHealthyContainers()));
} else if (disruptionBudgetPolicy instanceof UnhealthyTasksLimitDisruptionBudgetPolicy) {
builder.setUnhealthyTasksLimit(JobDisruptionBudget.UnhealthyTasksLimit.newBuilder().setLimitOfUnhealthyContainers(((UnhealthyTasksLimitDisruptionBudgetPolicy) disruptionBudgetPolicy).getLimitOfUnhealthyContainers()));
} else if (disruptionBudgetPolicy instanceof RelocationLimitDisruptionBudgetPolicy) {
builder.setRelocationLimit(JobDisruptionBudget.RelocationLimit.newBuilder().setLimit(((RelocationLimitDisruptionBudgetPolicy) disruptionBudgetPolicy).getLimit()));
}
DisruptionBudgetRate disruptionBudgetRate = coreDisruptionBudget.getDisruptionBudgetRate();
if (disruptionBudgetRate instanceof UnlimitedDisruptionBudgetRate) {
builder.setRateUnlimited(JobDisruptionBudget.RateUnlimited.newBuilder().build());
} else if (disruptionBudgetRate instanceof PercentagePerHourDisruptionBudgetRate) {
builder.setRatePercentagePerHour(JobDisruptionBudget.RatePercentagePerHour.newBuilder().setMaxPercentageOfContainersRelocatedInHour(((PercentagePerHourDisruptionBudgetRate) disruptionBudgetRate).getMaxPercentageOfContainersRelocatedInHour()));
} else if (disruptionBudgetRate instanceof RatePerIntervalDisruptionBudgetRate) {
RatePerIntervalDisruptionBudgetRate ratePerInterval = (RatePerIntervalDisruptionBudgetRate) disruptionBudgetRate;
builder.setRatePerInterval(JobDisruptionBudget.RatePerInterval.newBuilder().setIntervalMs(ratePerInterval.getIntervalMs()).setLimitPerInterval(ratePerInterval.getLimitPerInterval()).build());
} else if (disruptionBudgetRate instanceof RatePercentagePerIntervalDisruptionBudgetRate) {
RatePercentagePerIntervalDisruptionBudgetRate ratePercentagePerInterval = (RatePercentagePerIntervalDisruptionBudgetRate) disruptionBudgetRate;
builder.setRatePercentagePerInterval(JobDisruptionBudget.RatePercentagePerInterval.newBuilder().setIntervalMs(ratePercentagePerInterval.getIntervalMs()).setPercentageLimitPerInterval(ratePercentagePerInterval.getPercentageLimitPerInterval()).build());
}
return builder.addAllTimeWindows(toGrpcTimeWindows(coreDisruptionBudget.getTimeWindows())).addAllContainerHealthProviders(toGrpcContainerHealthProviders(coreDisruptionBudget.getContainerHealthProviders())).build();
}
use of com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudgetPolicy in project titus-control-plane by Netflix.
the class JobQuotaController method mergeQuotaControllers.
@VisibleForTesting
static List<QuotaController<Job<?>>> mergeQuotaControllers(List<QuotaController<Job<?>>> previousControllers, Job<?> job, V3JobOperations jobOperations, EffectiveJobDisruptionBudgetResolver effectiveDisruptionBudgetResolver, TitusRuntime titusRuntime) {
List<QuotaController<Job<?>>> quotaControllers = new ArrayList<>();
DisruptionBudget effectiveBudget = effectiveDisruptionBudgetResolver.resolve(job);
if (effectiveBudget.getDisruptionBudgetRate() instanceof PercentagePerHourDisruptionBudgetRate) {
QuotaController<Job<?>> newController = mergeQuotaController(job, previousControllers, JobPercentagePerHourRelocationRateController.class, () -> JobPercentagePerHourRelocationRateController.newJobPercentagePerHourRelocationRateController(job, effectiveDisruptionBudgetResolver, titusRuntime));
quotaControllers.add(newController);
} else if (effectiveBudget.getDisruptionBudgetRate() instanceof RatePercentagePerIntervalDisruptionBudgetRate) {
QuotaController<Job<?>> newController = mergeQuotaController(job, previousControllers, JobPercentagePerIntervalRateController.class, () -> JobPercentagePerIntervalRateController.newJobPercentagePerIntervalRateController(job, effectiveDisruptionBudgetResolver, titusRuntime));
quotaControllers.add(newController);
} else if (effectiveBudget.getDisruptionBudgetRate() instanceof RatePerIntervalDisruptionBudgetRate) {
QuotaController<Job<?>> newController = mergeQuotaController(job, previousControllers, RatePerIntervalRateController.class, () -> RatePerIntervalRateController.newRatePerIntervalRateController(job, effectiveDisruptionBudgetResolver, titusRuntime));
quotaControllers.add(newController);
}
DisruptionBudgetPolicy policy = effectiveBudget.getDisruptionBudgetPolicy();
if (policy instanceof RelocationLimitDisruptionBudgetPolicy) {
QuotaController<Job<?>> newController = mergeQuotaController(job, previousControllers, TaskRelocationLimitController.class, () -> new TaskRelocationLimitController(job, jobOperations, effectiveDisruptionBudgetResolver));
quotaControllers.add(newController);
}
return quotaControllers;
}
use of com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudgetPolicy in project titus-control-plane by Netflix.
the class DefaultTopologyFactory method getJobMaxSkew.
/**
* Get max skew from a job descriptor or compute a value based on the job type and its configured disruption budget.
*
* @return -1 if max skew not set or is invalid
*/
private int getJobMaxSkew(Job<?> job) {
String maxSkewAttr = job.getJobDescriptor().getAttributes().get(JobAttributes.JOB_ATTRIBUTES_SPREADING_MAX_SKEW);
if (maxSkewAttr != null) {
try {
int maxSkew = Integer.parseInt(maxSkewAttr);
if (maxSkew > 0) {
return maxSkew;
}
} catch (Exception ignore) {
}
}
DisruptionBudgetPolicy policy = job.getJobDescriptor().getDisruptionBudget().getDisruptionBudgetPolicy();
// Job spreading is only relevant for jobs that care about the availability.
if (!(policy instanceof AvailabilityPercentageLimitDisruptionBudgetPolicy)) {
return -1;
}
int jobSize = getJobDesiredSize(job);
if (jobSize <= 1) {
return -1;
}
double alpha = configuration.getJobSpreadingSkewAlpha();
if (alpha <= 0) {
return -1;
}
int skew = (int) (Math.floor(jobSize / alpha));
// The skew must be between 1 and the configured max skew.
return Math.max(1, Math.min(skew, configuration.getJobSpreadingMaxSkew()));
}
use of com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudgetPolicy in project titus-control-plane by Netflix.
the class JobQuotaController method buildQuotaTrackers.
@VisibleForTesting
static List<QuotaTracker> buildQuotaTrackers(Job<?> job, V3JobOperations jobOperations, EffectiveJobDisruptionBudgetResolver effectiveDisruptionBudgetResolver, ContainerHealthService containerHealthService, TitusRuntime titusRuntime) {
List<QuotaTracker> quotaTrackers = new ArrayList<>();
DisruptionBudget effectiveBudget = effectiveDisruptionBudgetResolver.resolve(job);
if (!effectiveBudget.getTimeWindows().isEmpty()) {
quotaTrackers.add(new TimeWindowQuotaTracker(effectiveBudget.getTimeWindows(), titusRuntime));
}
DisruptionBudgetPolicy policy = effectiveBudget.getDisruptionBudgetPolicy();
if (policy instanceof AvailabilityPercentageLimitDisruptionBudgetPolicy) {
quotaTrackers.add(UnhealthyTasksLimitTracker.percentageLimit(job, (AvailabilityPercentageLimitDisruptionBudgetPolicy) policy, jobOperations, containerHealthService));
} else if (policy instanceof UnhealthyTasksLimitDisruptionBudgetPolicy) {
quotaTrackers.add(UnhealthyTasksLimitTracker.absoluteLimit(job, (UnhealthyTasksLimitDisruptionBudgetPolicy) policy, jobOperations, containerHealthService));
}
return quotaTrackers;
}
use of com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudgetPolicy in project titus-control-plane by Netflix.
the class JobQuotaController method buildQuotaControllers.
@VisibleForTesting
static List<QuotaController<Job<?>>> buildQuotaControllers(Job<?> job, V3JobOperations jobOperations, EffectiveJobDisruptionBudgetResolver effectiveDisruptionBudgetResolver, TitusRuntime titusRuntime) {
List<QuotaController<Job<?>>> quotaControllers = new ArrayList<>();
DisruptionBudget effectiveBudget = effectiveDisruptionBudgetResolver.resolve(job);
if (effectiveBudget.getDisruptionBudgetRate() instanceof PercentagePerHourDisruptionBudgetRate) {
quotaControllers.add(JobPercentagePerHourRelocationRateController.newJobPercentagePerHourRelocationRateController(job, effectiveDisruptionBudgetResolver, titusRuntime));
} else if (effectiveBudget.getDisruptionBudgetRate() instanceof RatePercentagePerIntervalDisruptionBudgetRate) {
quotaControllers.add(JobPercentagePerIntervalRateController.newJobPercentagePerIntervalRateController(job, effectiveDisruptionBudgetResolver, titusRuntime));
} else if (effectiveBudget.getDisruptionBudgetRate() instanceof RatePerIntervalDisruptionBudgetRate) {
quotaControllers.add(RatePerIntervalRateController.newRatePerIntervalRateController(job, effectiveDisruptionBudgetResolver, titusRuntime));
}
DisruptionBudgetPolicy policy = effectiveBudget.getDisruptionBudgetPolicy();
if (policy instanceof RelocationLimitDisruptionBudgetPolicy) {
quotaControllers.add(new TaskRelocationLimitController(job, jobOperations, effectiveDisruptionBudgetResolver));
}
return quotaControllers;
}
Aggregations