### Question:
AssignmentLimiter { public synchronized void checkAssignFrom(String nodeIdentifier) { if (offlineNodes.contains(nodeIdentifier)) { return; } long now = ticker.read(); long start = delayedNodes.computeIfAbsent(nodeIdentifier, key -> now); Duration delay = new Duration(now - start, NANOSECONDS); if (delay.compareTo(reassignmentDelay) < 0) { throw new PrestoException(RAPTOR_REASSIGNMENT_DELAY, format( "Reassignment delay is in effect for node %s (elapsed: %s)", nodeIdentifier, delay.convertToMostSuccinctTimeUnit())); } if (lastOfflined.isPresent()) { delay = new Duration(now - lastOfflined.getAsLong(), NANOSECONDS); if (delay.compareTo(reassignmentInterval) < 0) { throw new PrestoException(RAPTOR_REASSIGNMENT_THROTTLE, format( "Reassignment throttle is in effect for node %s (elapsed: %s)", nodeIdentifier, delay.convertToMostSuccinctTimeUnit())); } } delayedNodes.remove(nodeIdentifier); offlineNodes.add(nodeIdentifier); lastOfflined = OptionalLong.of(now); } @Inject  AssignmentLimiter(NodeSupplier nodeSupplier, Ticker ticker, MetadataConfig config);  AssignmentLimiter(NodeSupplier nodeSupplier, Ticker ticker, Duration reassignmentDelay, Duration reassignmentInterval); @PostConstruct void start(); @PreDestroy void shutdown(); synchronized void checkAssignFrom(String nodeIdentifier);  }### Answer:
@Test public void testLimiter() { TestingTicker ticker = new TestingTicker(); AssignmentLimiter limiter = new AssignmentLimiter( ImmutableSet::of, ticker, new Duration(5, MINUTES), new Duration(10, MINUTES)); assertCheckFails(limiter, "A", RAPTOR_REASSIGNMENT_DELAY); ticker.increment(1, MINUTES); assertCheckFails(limiter, "A", RAPTOR_REASSIGNMENT_DELAY); assertCheckFails(limiter, "B", RAPTOR_REASSIGNMENT_DELAY); ticker.increment(4, MINUTES); limiter.checkAssignFrom("A"); assertCheckFails(limiter, "B", RAPTOR_REASSIGNMENT_DELAY); ticker.increment(1, MINUTES); assertCheckFails(limiter, "B", RAPTOR_REASSIGNMENT_THROTTLE); assertCheckFails(limiter, "C", RAPTOR_REASSIGNMENT_DELAY); ticker.increment(8, MINUTES); assertCheckFails(limiter, "B", RAPTOR_REASSIGNMENT_THROTTLE); assertCheckFails(limiter, "C", RAPTOR_REASSIGNMENT_THROTTLE); ticker.increment(1, MINUTES); limiter.checkAssignFrom("B"); assertCheckFails(limiter, "C", RAPTOR_REASSIGNMENT_THROTTLE); ticker.increment(9, MINUTES); assertCheckFails(limiter, "C", RAPTOR_REASSIGNMENT_THROTTLE); ticker.increment(1, MINUTES); limiter.checkAssignFrom("A"); ticker.increment(5, MINUTES); limiter.checkAssignFrom("A"); limiter.checkAssignFrom("B"); limiter.checkAssignFrom("C"); }