Package org.wildfly.naming.client
Class RetryContext
java.lang.Object
org.wildfly.naming.client.RetryContext
A context with an invocation life-span that maintains state useful to
retrying naming operations.
- Author:
- Jason T. Greene
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExplicitFailure(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.voidaddFailure(Throwable failure) Register an exception that was observed while attempting to execute an operation against a destination.voidaddTransientFail(URI destination) Registers a destination as having transiently failed.Gets the current destination being attempted by the invocation.Gets a list of exceptions for failures that have occurred while retrying this invocation.booleanReturns true if an explicit failure has been registered.booleanhasTransientlyFailed(URI destination) Indicates whether the specified destination has been registered as failing as part of this invocation.voidsetCurrentDestination(URI destination) Sets the current destination being attempted by the invocation.intReturn the current number of transient failures that have been registered against this context.
-
Constructor Details
-
RetryContext
public RetryContext()
-
-
Method Details
-
setCurrentDestination
Sets the current destination being attempted by the invocation.- Parameters:
destination- the current destination
-
currentDestination
Gets the current destination being attempted by the invocation.- Returns:
- the current destination
-
hasTransientlyFailed
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
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
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
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 toaddExplicitFailure(Throwable).- Returns:
- true if an explicit failure has been registered.
-
addFailure
Register an exception that was observed while attempting to execute an operation against a destination.- Parameters:
failure- the throwable thrown during a destination attempt
-