@InternalApi(value="For internal usage only")
public abstract class AbstractRetryingOperation<RequestT,ResponseT,ResultT>
extends io.grpc.ClientCall.Listener<ResponseT>
ClientCall.Listener
that retries a BigtableAsyncRpc
request.
For internal use only - public for technical reasons.
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractRetryingOperation.GrpcFuture<RespT> |
Modifier and Type | Field and Description |
---|---|
protected CallController<RequestT,ResponseT> |
callWrapper |
protected AbstractRetryingOperation.GrpcFuture<ResultT> |
completionFuture |
protected int |
failedCount |
protected static Logger |
LOG
Constant
LOG |
protected io.opencensus.trace.Span |
operationSpan |
protected Timer.Context |
operationTimerContext |
protected ScheduledExecutorService |
retryExecutorService |
protected RetryOptions |
retryOptions |
protected BigtableAsyncRpc<RequestT,ResponseT> |
rpc |
protected Timer.Context |
rpcTimerContext |
Constructor and Description |
---|
AbstractRetryingOperation(RetryOptions retryOptions,
RequestT request,
BigtableAsyncRpc<RequestT,ResponseT> retryableRpc,
DeadlineGenerator deadlineGenerator,
ScheduledExecutorService retryExecutorService,
io.grpc.Metadata originalMetadata,
com.google.api.core.ApiClock clock)
Constructor for AbstractRetryingRpcListener.
|
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels the RPC.
|
protected void |
cancel(String message)
Cancels the RPC with a specific message.
|
protected CallController<RequestT,ResponseT> |
createCallController() |
protected void |
finalizeStats(io.grpc.Status status) |
com.google.common.util.concurrent.ListenableFuture<ResultT> |
getAsyncResult()
Initial execution of the RPC.
|
ResultT |
getBlockingResult() |
protected BigtableRetriesExhaustedException |
getExhaustedRetriesException(io.grpc.Status status) |
protected Long |
getNextBackoff() |
protected RequestT |
getRetryRequest() |
protected Runnable |
getRunnable() |
boolean |
inRetryMode() |
protected boolean |
isRequestRetryable() |
protected boolean |
isStatusRetryable(io.grpc.Status status) |
void |
onClose(io.grpc.Status status,
io.grpc.Metadata trailers) |
protected void |
onError(io.grpc.Status status,
io.grpc.Metadata trailers) |
protected abstract boolean |
onOK(io.grpc.Metadata trailers)
A subclass has the opportunity to perform the final operations it needs now that the RPC is
successfully complete.
|
protected void |
performRetry(long nextBackOff) |
protected void |
resetStatusBasedBackoff()
Either a response was found, or a timeout event occurred.
|
protected void |
run()
Calls
BigtableAsyncRpc.newCall(CallOptions) and BigtableAsyncRpc.start(Object,
io.grpc.ClientCall.Listener, Metadata, ClientCall) } with this as the listener so that retries
happen correctly. |
protected void |
setException(Exception exception) |
protected static final Logger LOG
LOG
protected final BigtableAsyncRpc<RequestT,ResponseT> rpc
protected final RetryOptions retryOptions
protected final ScheduledExecutorService retryExecutorService
protected int failedCount
protected final AbstractRetryingOperation.GrpcFuture<ResultT> completionFuture
protected final CallController<RequestT,ResponseT> callWrapper
protected Timer.Context operationTimerContext
protected Timer.Context rpcTimerContext
protected final io.opencensus.trace.Span operationSpan
public AbstractRetryingOperation(RetryOptions retryOptions, RequestT request, BigtableAsyncRpc<RequestT,ResponseT> retryableRpc, DeadlineGenerator deadlineGenerator, ScheduledExecutorService retryExecutorService, io.grpc.Metadata originalMetadata, com.google.api.core.ApiClock clock)
retryOptions
- a RetryOptions
object.request
- a RequestT object.retryableRpc
- a BigtableAsyncRpc
object.deadlineGenerator
- a DeadlineGenerator
object.retryExecutorService
- a ScheduledExecutorService
object.originalMetadata
- a Metadata
object.clock
- a ApiClock
objectprotected CallController<RequestT,ResponseT> createCallController()
public void onClose(io.grpc.Status status, io.grpc.Metadata trailers)
onClose
in class io.grpc.ClientCall.Listener<ResponseT>
protected void finalizeStats(io.grpc.Status status)
protected void onError(io.grpc.Status status, io.grpc.Metadata trailers)
protected BigtableRetriesExhaustedException getExhaustedRetriesException(io.grpc.Status status)
protected void performRetry(long nextBackOff)
protected Runnable getRunnable()
protected boolean isRequestRetryable()
protected boolean isStatusRetryable(io.grpc.Status status)
protected void setException(Exception exception)
protected abstract boolean onOK(io.grpc.Metadata trailers)
protected Long getNextBackoff()
public boolean inRetryMode()
protected void resetStatusBasedBackoff()
protected void run()
BigtableAsyncRpc.newCall(CallOptions)
and BigtableAsyncRpc.start(Object,
io.grpc.ClientCall.Listener, Metadata, ClientCall)
} with this as the listener so that retries
happen correctly.protected RequestT getRetryRequest()
public com.google.common.util.concurrent.ListenableFuture<ResultT> getAsyncResult()
public void cancel()
public ResultT getBlockingResult()
protected void cancel(String message)
message
-