use of com.netflix.titus.api.jobmanager.model.job.disruptionbudget.UnlimitedDisruptionBudgetRate 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();
}
Aggregations