use of com.facebook.airlift.testing.TestingTicker in project presto by prestodb.
the class TestAssignmentLimiter method testLimiter.
@Test
public void testLimiter() {
TestingTicker ticker = new TestingTicker();
AssignmentLimiter limiter = new AssignmentLimiter(ImmutableSet::of, ticker, new Duration(5, MINUTES), new Duration(10, MINUTES), 0);
// 4:00
assertCheckFails(limiter, "A", RAPTOR_REASSIGNMENT_DELAY);
// 4:01
ticker.increment(1, MINUTES);
assertCheckFails(limiter, "A", RAPTOR_REASSIGNMENT_DELAY);
assertCheckFails(limiter, "B", RAPTOR_REASSIGNMENT_DELAY);
// 4:05
ticker.increment(4, MINUTES);
limiter.checkAssignFrom("A");
assertCheckFails(limiter, "B", RAPTOR_REASSIGNMENT_DELAY);
// 4:06
ticker.increment(1, MINUTES);
assertCheckFails(limiter, "B", RAPTOR_REASSIGNMENT_THROTTLE);
assertCheckFails(limiter, "C", RAPTOR_REASSIGNMENT_DELAY);
// 4:14
ticker.increment(8, MINUTES);
assertCheckFails(limiter, "B", RAPTOR_REASSIGNMENT_THROTTLE);
assertCheckFails(limiter, "C", RAPTOR_REASSIGNMENT_THROTTLE);
// 4:15
ticker.increment(1, MINUTES);
limiter.checkAssignFrom("B");
assertCheckFails(limiter, "C", RAPTOR_REASSIGNMENT_THROTTLE);
// 4:24
ticker.increment(9, MINUTES);
assertCheckFails(limiter, "C", RAPTOR_REASSIGNMENT_THROTTLE);
// 4:25
ticker.increment(1, MINUTES);
limiter.checkAssignFrom("A");
// 4:30
ticker.increment(5, MINUTES);
limiter.checkAssignFrom("A");
limiter.checkAssignFrom("B");
limiter.checkAssignFrom("C");
}
Aggregations