com.google.cloud.bigtable.grpc.async
Class AbstractRetryingOperation<RequestT,ResponseT,ResultT>
- java.lang.Object
-
- io.grpc.ClientCall.Listener<ResponseT>
-
- com.google.cloud.bigtable.grpc.async.AbstractRetryingOperation<RequestT,ResponseT,ResultT>
-
- Direct Known Subclasses:
- RetryingMutateRowsOperation, RetryingReadRowsOperation, RetryingStreamOperation, RetryingUnaryOperation
public abstract class AbstractRetryingOperation<RequestT,ResponseT,ResultT> extends io.grpc.ClientCall.Listener<ResponseT>
AClientCall.Listener
that retries aBigtableAsyncRpc
request.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description protected class
AbstractRetryingOperation.GrpcFuture<RespT>
-
Field Summary
Fields Modifier and Type Field and Description protected CallController<RequestT,ResponseT>
callWrapper
protected AbstractRetryingOperation.GrpcFuture<ResultT>
completionFuture
protected int
failedCount
protected static Logger
LOG
ConstantLOG
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 Summary
Constructors 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.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods 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)
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 theCallOptions
that a user set for the entire Operation, which can span multiple RPCs/retries.protected RequestT
getRetryRequest()
protected io.grpc.CallOptions
getRpcCallOptions()
Create anCallOptions
that has a fail safe RPC deadline to make sure that unary operations don't stop responding.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()
CallsBigtableAsyncRpc.newCall(CallOptions)
andBigtableAsyncRpc.start(Object, io.grpc.ClientCall.Listener, Metadata, ClientCall)
} with this as the listener so that retries happen correctly.protected void
setException(Exception exception)
-
-
-
Field Detail
-
LOG
protected static final Logger LOG
ConstantLOG
-
UNARY_DEADLINE_MINUTES
protected static final long UNARY_DEADLINE_MINUTES
- See Also:
- Constant Field Values
-
rpc
protected final BigtableAsyncRpc<RequestT,ResponseT> rpc
-
retryOptions
protected final RetryOptions retryOptions
-
retryExecutorService
protected final ScheduledExecutorService retryExecutorService
-
failedCount
protected int failedCount
-
completionFuture
protected final AbstractRetryingOperation.GrpcFuture<ResultT> completionFuture
-
callWrapper
protected final CallController<RequestT,ResponseT> callWrapper
-
operationTimerContext
protected Timer.Context operationTimerContext
-
rpcTimerContext
protected Timer.Context rpcTimerContext
-
operationSpan
protected final io.opencensus.trace.Span operationSpan
-
-
Constructor Detail
-
AbstractRetryingOperation
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)
Constructor for AbstractRetryingRpcListener.- Parameters:
retryOptions
- aRetryOptions
object.request
- a RequestT object.retryableRpc
- aBigtableAsyncRpc
object.callOptions
- aCallOptions
object.retryExecutorService
- aScheduledExecutorService
object.originalMetadata
- aMetadata
object.clock
- aApiClock
object
-
-
Method Detail
-
createCallController
protected CallController<RequestT,ResponseT> createCallController()
-
onClose
public void onClose(io.grpc.Status status, io.grpc.Metadata trailers)
- Overrides:
onClose
in classio.grpc.ClientCall.Listener<ResponseT>
-
finalizeStats
protected void finalizeStats(io.grpc.Status status)
-
onError
protected void onError(io.grpc.Status status, io.grpc.Metadata trailers)
-
getExhaustedRetriesException
protected BigtableRetriesExhaustedException getExhaustedRetriesException(io.grpc.Status status)
-
performRetry
protected void performRetry(long nextBackOff)
-
getRunnable
protected Runnable getRunnable()
-
isRequestRetryable
protected boolean isRequestRetryable()
-
setException
protected void setException(Exception exception)
-
onOK
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. If a subclass has to retry, due to the message, this method will return false- Returns:
- true if the operation was really completed.
-
getNextBackoff
protected Long getNextBackoff()
-
inRetryMode
public boolean inRetryMode()
-
resetStatusBasedBackoff
protected void resetStatusBasedBackoff()
Either a response was found, or a timeout event occurred. Reset the information relating to Status oriented exception handling.
-
run
protected void run()
CallsBigtableAsyncRpc.newCall(CallOptions)
andBigtableAsyncRpc.start(Object, io.grpc.ClientCall.Listener, Metadata, ClientCall)
} with this as the listener so that retries happen correctly.
-
getOperationCallOptions
protected io.grpc.CallOptions getOperationCallOptions()
Returns theCallOptions
that a user set for the entire Operation, which can span multiple RPCs/retries.- Returns:
- The
CallOptions
-
getRpcCallOptions
protected io.grpc.CallOptions getRpcCallOptions()
Create anCallOptions
that has a fail safe RPC deadline to make sure that unary operations don't stop responding. This will have to be overridden for streaming RPCs like read rows.The logic is as follows:
- If the user provides a deadline, use the deadline
- Else If this is a streaming read, don't set an explicit deadline. The
Watchdog
will handle unresponsiveness - Else Set a deadline of
UNARY_DEADLINE_MINUTES
minutes deadline.
- Returns:
- a
CallOptions
- See Also:
Watchdog which handles unresponsiveness for streaming reads.
-
isStreamingRead
protected boolean isStreamingRead()
-
getRetryRequest
protected RequestT getRetryRequest()
-
getAsyncResult
public ListenableFuture<ResultT> getAsyncResult()
Initial execution of the RPC.
-
cancel
public void cancel()
Cancels the RPC.
-
getBlockingResult
public ResultT getBlockingResult()
-
cancel
protected void cancel(String message)
Cancels the RPC with a specific message.- Parameters:
message
-
-
-