@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 |
protected static long |
UNARY_DEADLINE_MINUTES |
Constructor and Description |
---|
AbstractRetryingOperation(RetryOptions retryOptions,
RequestT request,
BigtableAsyncRpc<RequestT,ResponseT> retryableRpc,
io.grpc.CallOptions callOptions,
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 io.grpc.CallOptions |
getOperationCallOptions()
Returns the
CallOptions that a user set for the entire Operation, which can span
multiple RPCs/retries. |
protected RequestT |
getRetryRequest() |
protected io.grpc.CallOptions |
getRpcCallOptions()
Create an
CallOptions that has a fail safe RPC deadline to make sure that unary
operations don't hang. |
protected Runnable |
getRunnable() |
boolean |
inRetryMode() |
protected boolean |
isRequestRetryable() |
protected boolean |
isStreamingRead() |
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 static final long UNARY_DEADLINE_MINUTES
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, io.grpc.CallOptions callOptions, ScheduledExecutorService retryExecutorService, io.grpc.Metadata originalMetadata, com.google.api.core.ApiClock clock)
retryOptions
- a RetryOptions
object.request
- a RequestT object.retryableRpc
- a BigtableAsyncRpc
object.callOptions
- a CallOptions
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 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 io.grpc.CallOptions getOperationCallOptions()
CallOptions
that a user set for the entire Operation, which can span
multiple RPCs/retries.CallOptions
protected io.grpc.CallOptions getRpcCallOptions()
CallOptions
that has a fail safe RPC deadline to make sure that unary
operations don't hang. This will have to be overridden for streaming RPCs like read rows.
The logic is as follows:
Watchdog
will handle hanging
UNARY_DEADLINE_MINUTES
minutes deadline.
CallOptions
Watchdog which handles hanging for streaming
reads.
protected boolean isStreamingRead()
protected RequestT getRetryRequest()
public com.google.common.util.concurrent.ListenableFuture<ResultT> getAsyncResult()
public void cancel()
public ResultT getBlockingResult()
protected void cancel(String message)
message
-