public class RpcThrottler extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
RpcThrottler.RetryHandler |
Modifier and Type | Field and Description |
---|---|
protected static Logger |
LOG
Constant
LOG |
Constructor and Description |
---|
RpcThrottler(ResourceLimiter resourceLimiter)
Constructor for RpcThrottler.
|
Modifier and Type | Method and Description |
---|---|
<T> com.google.common.util.concurrent.FutureCallback<T> |
addCallback(com.google.common.util.concurrent.ListenableFuture<T> future,
long id)
Add a callback to a Future representing an RPC call with the given
operation id that will clean upon completion and reclaim any utilized resources.
|
void |
awaitCompletion()
Blocks until all outstanding RPCs and retries have completed
|
long |
getMaxHeapSize()
getMaxHeapSize.
|
boolean |
hasInflightRequests()
hasInflightRequests.
|
void |
onRetryCompletion(long id)
onRetryCompletion.
|
long |
registerOperationWithHeapSize(long heapSize)
Register a new RPC operation.
|
<T> long |
registerRetry(RpcThrottler.RetryHandler handler)
Registers a retry, if a retry is necessary, it
will be complete before a call to
awaitCompletion returns. |
protected static final Logger LOG
LOG
public RpcThrottler(ResourceLimiter resourceLimiter)
Constructor for RpcThrottler.
resourceLimiter
- a ResourceLimiter
object.public long registerOperationWithHeapSize(long heapSize) throws InterruptedException
addCallback
.heapSize
- The serialized size of the RPCInterruptedException
- if any.public <T> com.google.common.util.concurrent.FutureCallback<T> addCallback(com.google.common.util.concurrent.ListenableFuture<T> future, long id)
registerOperationWithHeapSize
.T
- a T object.future
- a ListenableFuture
object.id
- a long.FutureCallback
object.public <T> long registerRetry(RpcThrottler.RetryHandler handler)
awaitCompletion
returns.
Retries do not count against any RPC resource limits.T
- a T object.public void awaitCompletion() throws InterruptedException
InterruptedException
- if any.public long getMaxHeapSize()
getMaxHeapSize.
public boolean hasInflightRequests()
hasInflightRequests.
public void onRetryCompletion(long id)
onRetryCompletion.
id
- a long.