RatePerIntervalRateController extends AbstractRatePerIntervalRateController { public static RatePerIntervalRateController newRatePerIntervalRateController(Job<?> job, EffectiveJobDisruptionBudgetResolver budgetResolver, TitusRuntime titusRuntime) { RatePerIntervalDisruptionBudgetRate rate = (RatePerIntervalDisruptionBudgetRate) budgetResolver.resolve(job).getDisruptionBudgetRate(); return new RatePerIntervalRateController(job, rate.getIntervalMs(), rate.getLimitPerInterval(), budgetResolver, titusRuntime); } private  RatePerIntervalRateController(Job<?> job,
                                          long intervalMs,
                                          long evictionsPerInterval,
                                          EffectiveJobDisruptionBudgetResolver budgetResolver,
                                          TitusRuntime titusRuntime); private  RatePerIntervalRateController(Job<?> newJob,
                                          long intervalMs,
                                          long evictionsPerInterval,
                                          RatePerIntervalRateController previous); @Override RatePerIntervalRateController update(Job<?> newJob); static RatePerIntervalRateController newRatePerIntervalRateController(Job<?> job,
                                                                                 EffectiveJobDisruptionBudgetResolver budgetResolver,
                                                                                 TitusRuntime titusRuntime);  }
@Test public void testQuota() { RatePerIntervalRateController quotaController = newRatePerIntervalRateController( exceptRate(REFERENCE_JOB, ratePerInterval(WINDOW_MS, 5)), SelfJobDisruptionBudgetResolver.getInstance(), titusRuntime ); assertThat(quotaController.getQuota(JOB_REFERENCE).getQuota()).isEqualTo(5); consumeAtInterval(quotaController, 5, CONSUME_INTERVAL); assertThat(quotaController.getQuota(JOB_REFERENCE).getQuota()).isEqualTo(0); clock.advanceTime(CONSUME_INTERVAL); clock.advanceTime(CONSUME_INTERVAL); assertThat(quotaController.consume("someTaskId").isApproved()).isTrue(); clock.advanceTime(Duration.ofHours(2)); assertThat(quotaController.getQuota(JOB_REFERENCE).getQuota()).isEqualTo(5); }