Class RetryContext


  • public final class RetryContext
    extends Object
    A context with an invocation life-span that maintains state useful to retrying naming operations.
    Author:
    Jason T. Greene
    • Constructor Detail

      • RetryContext

        public RetryContext()
    • Method Detail

      • setCurrentDestination

        public void setCurrentDestination​(URI destination)
        Sets the current destination being attempted by the invocation.
        Parameters:
        destination - the current destination
      • currentDestination

        public URI currentDestination()
        Gets the current destination being attempted by the invocation.
        Returns:
        the current destination
      • hasTransientlyFailed

        public boolean hasTransientlyFailed​(URI destination)
        Indicates whether the specified destination has been registered as failing as part of this invocation. Note that this will only return true for destinations that have transiently failed. If there is a blocklist entry for a destination, then it is not recorded as a transient failure.
        Parameters:
        destination - the destination to check
        Returns:
        true if a transient failure is registered
      • addTransientFail

        public void addTransientFail​(URI destination)
        Registers a destination as having transiently failed. Destinations that have transiently failed should not be retried in the corresponding invocation of this context. However, future invocations should retry, unlike a blocklisted destination, which instead utilizes time-based back-off.
        Parameters:
        destination - the destination to record a transient failure
      • transientFailCount

        public int transientFailCount()
        Return the current number of transient failures that have been registered against this context.
        Returns:
        the number of transient failures registered
      • getFailures

        public List<Throwable> getFailures()
        Gets a list of exceptions for failures that have occurred while retrying this invocation. Note that this list may include both blocklisted and transient failures, and is not necessarily exhaustive. This list is purely intended for informational error-reporting. Callers should not make assumptions based on the content of it.
        Returns:
        a list of throwables thrown while attempting contact with a destination
      • addExplicitFailure

        public void addExplicitFailure​(Throwable failure)
        Indicates to a naming provider that this exception should be thrown, as opposed to a "no more destinations" summary exception, if no other destinations are successful during the invocation.
        Parameters:
        failure - the Throwable that should be thrown if no other destinations succeed.
      • hasExplicitFailure

        public boolean hasExplicitFailure()
        Returns true if an explicit failure has been registered. This occurs as the result of a call to addExplicitFailure(Throwable).
        Returns:
        true if an explicit failure has been registered.
      • addFailure

        public void addFailure​(Throwable failure)
        Register an exception that was observed while attempting to execute an operation against a destination.
        Parameters:
        failure - the throwable thrown during a destination attempt