Package oracle.nosql.driver
Class DefaultRetryHandler
java.lang.Object
oracle.nosql.driver.DefaultRetryHandler
- All Implemented Interfaces:
RetryHandler
Default retry handler.
This may be extended by clients for specific use cases.
The default retry handler decides when and for how long retries will
be attempted. See
RetryHandler
for more information on
retry handlers.-
Method Summary
Modifier and TypeMethodDescriptionstatic int
computeBackoffDelay
(Request request, int fixedDelayMs) Compute an incremental backoff delay in milliseconds.void
delay
(Request request, int numRetries, RetryableException re) Delay (sleep) during retry cycle.boolean
doRetry
(Request request, int numRetries, RetryableException re) Decide whether to retry or not.int
Returns the number of retries that this handler instance will allow before the exception is thrown to the application.
-
Method Details
-
getNumRetries
public int getNumRetries()Description copied from interface:RetryHandler
Returns the number of retries that this handler instance will allow before the exception is thrown to the application.- Specified by:
getNumRetries
in interfaceRetryHandler
- Returns:
- the max number of retries
-
doRetry
Decide whether to retry or not. Default behavior is to *not* retry OperationThrottlingException because the retry time is likely much longer than normal because they are DDL operations. Read and Write throttling exceptions are always retryable. Otherwise check the request itself to see if it should not be retried.- Specified by:
doRetry
in interfaceRetryHandler
- Parameters:
request
- the Request that has triggered the exceptionnumRetries
- the number of retries that have occurred for the operationre
- the exception that was thrown- Returns:
- true if the operation should be retried, false if not, causing the exception to be thrown to the application.
-
delay
Delay (sleep) during retry cycle. If delayMS is non-zero, use it. Otherwise, use an incremental backoff algorithm to compute the time of delay.- Specified by:
delay
in interfaceRetryHandler
- Parameters:
request
- the Request that has triggered the exceptionnumRetries
- the number of retries that have occurred for the operationre
- the exception that was thrown
-
computeBackoffDelay
Compute an incremental backoff delay in milliseconds. This method also checks the request's timeout and ensures the delay will not exceed the specified timeout.- Parameters:
request
- The request object being executedfixedDelayMs
- A specific delay to use and check for timeout. Pass zero to use the default backoff logic.- Returns:
- The number of milliseconds to delay. If zero, do not delay at all.
-