@Test public void testQuota() { JobPercentagePerHourRelocationRateController quotaController = newJobPercentagePerHourRelocationRateController( exceptRate(REFERENCE_JOB, hourlyRatePercentage(50)), SelfJobDisruptionBudgetResolver.getInstance(), titusRuntime ); assertThat(quotaController.getQuota(JOB_REFERENCE).getQuota()).isEqualTo(5); consumeAtInterval(quotaController, 5, TEN_MINUTES); assertThat(quotaController.getQuota(JOB_REFERENCE).getQuota()).isEqualTo(0); clock.advanceTime(TEN_MINUTES); clock.advanceTime(TEN_MINUTES); assertThat(quotaController.consume("someTaskId").isApproved()).isTrue(); clock.advanceTime(Duration.ofHours(2)); assertThat(quotaController.getQuota(JOB_REFERENCE).getQuota()).isEqualTo(5); }
public static JobPercentagePerHourRelocationRateController newJobPercentagePerHourRelocationRateController(Job<?> job, EffectiveJobDisruptionBudgetResolver budgetResolver, TitusRuntime titusRuntime) { Pair<Long, Integer> pair = getIntervalLimitPair(job, budgetResolver); return new JobPercentagePerHourRelocationRateController(job, pair.getLeft(), pair.getRight(), budgetResolver, titusRuntime); }
JobPercentagePerHourRelocationRateController extends AbstractRatePerIntervalRateController { public static JobPercentagePerHourRelocationRateController newJobPercentagePerHourRelocationRateController(Job<?> job, EffectiveJobDisruptionBudgetResolver budgetResolver, TitusRuntime titusRuntime) { Pair<Long, Integer> pair = getIntervalLimitPair(job, budgetResolver); return new JobPercentagePerHourRelocationRateController(job, pair.getLeft(), pair.getRight(), budgetResolver, titusRuntime); } }
JobPercentagePerHourRelocationRateController extends AbstractRatePerIntervalRateController { public static JobPercentagePerHourRelocationRateController newJobPercentagePerHourRelocationRateController(Job<?> job, EffectiveJobDisruptionBudgetResolver budgetResolver, TitusRuntime titusRuntime) { Pair<Long, Integer> pair = getIntervalLimitPair(job, budgetResolver); return new JobPercentagePerHourRelocationRateController(job, pair.getLeft(), pair.getRight(), budgetResolver, titusRuntime); } private  JobPercentagePerHourRelocationRateController(Job<?> job,
                                                         long intervalMs,
                                                         long evictionsPerInterval,
                                                         EffectiveJobDisruptionBudgetResolver budgetResolver,
                                                         TitusRuntime titusRuntime); private  JobPercentagePerHourRelocationRateController(Job<?> newJob,
                                                         long intervalMs,
                                                         long evictionsPerInterval,
                                                         JobPercentagePerHourRelocationRateController previous); }
JobPercentagePerHourRelocationRateController extends AbstractRatePerIntervalRateController { public static JobPercentagePerHourRelocationRateController newJobPercentagePerHourRelocationRateController(Job<?> job, EffectiveJobDisruptionBudgetResolver budgetResolver, TitusRuntime titusRuntime) { Pair<Long, Integer> pair = getIntervalLimitPair(job, budgetResolver); return new JobPercentagePerHourRelocationRateController(job, pair.getLeft(), pair.getRight(), budgetResolver, titusRuntime); } private  JobPercentagePerHourRelocationRateController(Job<?> job,
                                                         long intervalMs,
                                                         long evictionsPerInterval,
                                                         EffectiveJobDisruptionBudgetResolver budgetResolver,
                                                         TitusRuntime titusRuntime); private  JobPercentagePerHourRelocationRateController(Job<?> newJob,
                                                         long intervalMs,
                                                         long evictionsPerInterval,
                                                         JobPercentagePerHourRelocationRateController previous); @Override JobPercentagePerHourRelocationRateController update(Job<?> newJob); static JobPercentagePerHourRelocationRateController newJobPercentagePerHourRelocationRateController(Job<?> job,
                                                                                                               EffectiveJobDisruptionBudgetResolver budgetResolver,
                                                                                                               TitusRuntime titusRuntime); }
JobPercentagePerHourRelocationRateController extends AbstractRatePerIntervalRateController { public static JobPercentagePerHourRelocationRateController newJobPercentagePerHourRelocationRateController(Job<?> job, EffectiveJobDisruptionBudgetResolver budgetResolver, TitusRuntime titusRuntime) { Pair<Long, Integer> pair = getIntervalLimitPair(job, budgetResolver); return new JobPercentagePerHourRelocationRateController(job, pair.getLeft(), pair.getRight(), budgetResolver, titusRuntime); } private  JobPercentagePerHourRelocationRateController(Job<?> job,
                                                         long intervalMs,
                                                         long evictionsPerInterval,
                                                         EffectiveJobDisruptionBudgetResolver budgetResolver,
                                                         TitusRuntime titusRuntime); private  JobPercentagePerHourRelocationRateController(Job<?> newJob,
                                                         long intervalMs,
                                                         long evictionsPerInterval,
                                                         JobPercentagePerHourRelocationRateController previous); @Override JobPercentagePerHourRelocationRateController update(Job<?> newJob); static JobPercentagePerHourRelocationRateController newJobPercentagePerHourRelocationRateController(Job<?> job,
                                                                                                               EffectiveJobDisruptionBudgetResolver budgetResolver,
                                                                                                               TitusRuntime titusRuntime);  }