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