@Test public void testThrottling() throws InterruptedException { Meter meter = new Meter(); for (int i = 0; i < 100; i++) { Assert.assertTrue(this.limiter.acquirePermits(1) != null); meter.mark(); Thread.sleep((RANDOM.nextInt() & Integer.MAX_VALUE) % 10); } Assert.assertTrue(DoubleMath.fuzzyEquals(meter.getMeanRate(), 20d, 20d * 0.05)); }
@Override public Closeable acquirePermits(long permits) throws InterruptedException { this.rateLimiter.acquire(Ints.checkedCast(permits)); return NO_OP_CLOSEABLE; }
RateBasedLimiter extends NonRefillableLimiter { @Override public Closeable acquirePermits(long permits) throws InterruptedException { this.rateLimiter.acquire(Ints.checkedCast(permits)); return NO_OP_CLOSEABLE; } }
RateBasedLimiter extends NonRefillableLimiter { @Override public Closeable acquirePermits(long permits) throws InterruptedException { this.rateLimiter.acquire(Ints.checkedCast(permits)); return NO_OP_CLOSEABLE; } RateBasedLimiter(double rateLimit);  RateBasedLimiter(double rateLimit, TimeUnit timeUnit); }
RateBasedLimiter extends NonRefillableLimiter { @Override public Closeable acquirePermits(long permits) throws InterruptedException { this.rateLimiter.acquire(Ints.checkedCast(permits)); return NO_OP_CLOSEABLE; } RateBasedLimiter(double rateLimit);  RateBasedLimiter(double rateLimit, TimeUnit timeUnit); @Override void start(); @Override Closeable acquirePermits(long permits); @Override void stop(); }
RateBasedLimiter extends NonRefillableLimiter { @Override public Closeable acquirePermits(long permits) throws InterruptedException { this.rateLimiter.acquire(Ints.checkedCast(permits)); return NO_OP_CLOSEABLE; } RateBasedLimiter(double rateLimit);  RateBasedLimiter(double rateLimit, TimeUnit timeUnit); @Override void start(); @Override Closeable acquirePermits(long permits); @Override void stop();  }