RetryHandler¶
-
class
borneo.
RetryHandler
[source]¶ Bases:
object
RetryHandler is called by the request handling system when a
RetryableException
is thrown. It controls the number of retries as well as frequency of retries using a delaying algorithm. A default RetryHandler is always configured on aNoSQLHandle
instance and can be controlled or overridden usingNoSQLHandleConfig.set_retry_handler()
andNoSQLHandleConfig.configure_default_retry_handler()
.It is not recommended that applications rely on a RetryHandler for regulating provisioned throughput. It is best to add rate limiting to the application based on a table’s capacity and access patterns to avoid throttling exceptions: see
NoSQLHandleConfig.set_rate_limiting_enabled()
.Instances of this class must be immutable so they can be shared among threads.
Methods Summary
delay
(request, num_retried, re)This method is called when a RetryableException
is thrown and it is determined that the request will be retried based on the return value ofdo_retry()
.do_retry
(request, num_retried, re)This method is called when a RetryableException
is thrown and determines whether to perform a retry or not based on the parameters.get_num_retries
()Returns the number of retries that this handler instance will allow before the exception is thrown to the application. Methods Documentation
-
delay
(request, num_retried, re)[source]¶ This method is called when a
RetryableException
is thrown and it is determined that the request will be retried based on the return value ofdo_retry()
. It provides a delay between retries. Most implementations will sleep for some period of time. The method should not return until the desired delay period has passed. Implementations should not busy-wait in a tight loop.If delayMS is non-zero, use it. Otherwise, use a exponential backoff algorithm to compute the time of delay.
If retry-able exception is SecurityInfoNotReadyException, delay for SEC_RETRY_DELAY_MS when number of retries is smaller than 10. Otherwise, use the exponential backoff algorithm to compute the time of delay.
Parameters: - request (Request) – request to execute.
- num_retried (int) – the number of retries that have occurred for the operation.
- re (RetryableException) – the exception that was thrown.
Raises: IllegalArgumentException – raises the exception if num_retried is not a positive number.
-
do_retry
(request, num_retried, re)[source]¶ This method is called when a
RetryableException
is thrown and determines whether to perform a retry or not based on the parameters.Default behavior is to not retry OperationThrottlingException because the retry time is likely much longer than normal because they are DDL operations. In addition, not retry any requests that should not be retired: TableRequest, ListTablesRequest, GetTableRequest, TableUsageRequest, GetIndexesRequest.
Always retry SecurityInfoNotReadyException until exceed the request timeout. It’s not restrained by the maximum retries configured for this handler, the driver with retry handler with 0 retry setting would still retry this exception.
Parameters: - request (Request) – the request that has triggered the exception.
- num_retried (int) – the number of retries that have occurred for the operation.
- re (RetryableException) – 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.
Return type: bool
Raises: IllegalArgumentException – raises the exception if num_retried is not a positive number.
-