TableRateLimiter { int getCredits(K key, V value, Object ... args) { return (creditFn == null) ? 1 : creditFn.getCredits(key, value, args); } TableRateLimiter(String tableId, RateLimiter rateLimiter, CreditFunction<K, V> creditFn, String tag); void setTimerMetric(Timer timer); void throttle(K key, Object ... args); void throttle(K key, V value, Object ... args); void throttle(int opId, Object ... args); void throttle(Collection<K> keys, Object ... args); void throttleRecords(Collection<Entry<K, V>> records, Object ... args);  }
@Test public void testCreditOpId() { TableRateLimiter<String, String> rateLimitHelper = getThrottler(); Assert.assertEquals(1, rateLimitHelper.getCredits(1, 2)); }
@Test public void testCreditKeyOnly() { TableRateLimiter<String, String> rateLimitHelper = getThrottler(); Assert.assertEquals(3, rateLimitHelper.getCredits("abc", null)); }
@Test public void testCreditKeyValue() { TableRateLimiter<String, String> rateLimitHelper = getThrottler(); Assert.assertEquals(6, rateLimitHelper.getCredits("abc", "efg")); }
@Test public void testCreditKeys() { TableRateLimiter<String, String> rateLimitHelper = getThrottler(); Assert.assertEquals(9, rateLimitHelper.getCredits(Arrays.asList("abc", "efg", "hij"))); }