K
- type of the table keyV
- type of the table recordpublic class TableRateLimiter<K,V>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
TableRateLimiter.CreditFunction<K,V>
Function interface for providing rate limiting credits for each table record.
|
Constructor and Description |
---|
TableRateLimiter(java.lang.String tableId,
RateLimiter rateLimiter,
TableRateLimiter.CreditFunction<K,V> creditFn,
java.lang.String tag) |
Modifier and Type | Method and Description |
---|---|
void |
setTimerMetric(Timer timer)
Set up waitTimeMetric metric for latency reporting due to throttling.
|
void |
throttle(java.util.Collection<K> keys,
java.lang.Object... args)
Throttle a request with a collection of keys as the argument if necessary.
|
void |
throttle(int opId,
java.lang.Object... args)
Throttle a request with opId and associated arguments
|
void |
throttle(K key,
java.lang.Object... args)
Throttle a request with a key argument if necessary.
|
void |
throttle(K key,
V value,
java.lang.Object... args)
Throttle a request with both the key and value arguments if necessary.
|
void |
throttleRecords(java.util.Collection<Entry<K,V>> records,
java.lang.Object... args)
Throttle a request with a collection of table records as the argument if necessary.
|
public TableRateLimiter(java.lang.String tableId, RateLimiter rateLimiter, TableRateLimiter.CreditFunction<K,V> creditFn, java.lang.String tag)
tableId
- table id of the table to be rate limitedrateLimiter
- actual rate limiter instance to be usedcreditFn
- function for deriving the credits for each requesttag
- tag to be used with the rate limiterpublic void setTimerMetric(Timer timer)
timer
- waitTimeMetric metricpublic void throttle(K key, java.lang.Object... args)
key
- key used for the table requestargs
- additional argumentspublic void throttle(K key, V value, java.lang.Object... args)
key
- key used for the table requestvalue
- value used for the table requestargs
- additional argumentspublic void throttle(int opId, java.lang.Object... args)
opId
- operation Idargs
- associated argumentspublic void throttle(java.util.Collection<K> keys, java.lang.Object... args)
keys
- collection of keys used for the table requestargs
- additional arguments