Package oracle.nosql.driver

## Class DefaultRetryHandler

- java.lang.Object
- - oracle.nosql.driver.DefaultRetryHandler

- All Implemented Interfaces:
    `RetryHandler`

      public class DefaultRetryHandler
      extends Object
      implements 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

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static 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` | `getNumRetries()` | Returns the number of retries that this handler instance will allow before the exception is thrown to the application.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### 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 interface `RetryHandler`
      Returns:
        the max number of retries

    - #### doRetry

          public boolean doRetry​(Request request,
                                 int numRetries,
                                 RetryableException re)

      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. In addition, *not* retry any requests that should not be retried: TableRequest, ListTablesRequest, GetTableRequest, TableUsageRequest, GetIndexesRequest.
      Specified by:
        `doRetry` in interface `RetryHandler`
      Parameters:
        `request` - the Request that has triggered the exception
        `numRetries` - the number of retries that have occurred for the operation
        `re` - 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

          public void delay​(Request request,
                            int numRetries,
                            RetryableException re)

      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 interface `RetryHandler`
      Parameters:
        `request` - the Request that has triggered the exception
        `numRetries` - the number of retries that have occurred for the operation
        `re` - the exception that was thrown

    - #### computeBackoffDelay

          public static int computeBackoffDelay​(Request request,
                                                int fixedDelayMs)

      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 executed
        `fixedDelayMs` - 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.