Class TarantoolRequestRetryPolicies.AttemptsBoundRetryPolicy<T extends Predicate<Throwable>>

  • Type Parameters:
    T - exception checking predicate type
    All Implemented Interfaces:
    RequestRetryPolicy
    Enclosing class:
    TarantoolRequestRetryPolicies

    public static final class TarantoolRequestRetryPolicies.AttemptsBoundRetryPolicy<T extends Predicate<Throwable>>
    extends Object
    implements RequestRetryPolicy
    Retry policy that accepts a maximum number of attempts and an exception checking predicate. If the exception check passes and there are any attempts left, the policy returns true.
    • Constructor Detail

      • AttemptsBoundRetryPolicy

        public AttemptsBoundRetryPolicy​(int attempts,
                                        long requestTimeout,
                                        long delay,
                                        T exceptionCheck)
        Basic constructor with timeout
        Parameters:
        attempts - maximum number of retry attempts
        requestTimeout - timeout for one retry attempt, in milliseconds
        delay - delay between attempts, in milliseconds
        exceptionCheck - predicate checking whether the given exception may be retried
    • Method Detail

      • getRequestTimeout

        public long getRequestTimeout()
        Description copied from interface: RequestRetryPolicy
        Get timeout value for one retry attempt. The default value is 1 hour.
        Specified by:
        getRequestTimeout in interface RequestRetryPolicy
        Returns:
        timeout value (ms), should be greater or equal to 0
      • canRetryRequest

        public boolean canRetryRequest​(Throwable throwable)
        Description copied from interface: RequestRetryPolicy
        A callback called when the request ends with an exception. Should return true if and only if the request may be performed again (e.g. it is a timeout exception and it indicates only that the current server is overloaded). This may depend not only on the exception type, but also on the other conditions like the allowed number of retries or the maximum request execution time.

        Effective use of the retry policies may be achieved by combining them with multiple server connections and a ConnectionSelectionStrategy.

        Specified by:
        canRetryRequest in interface RequestRetryPolicy
        Parameters:
        throwable - exception a request failed with
        Returns:
        true if the request may be retried