Class RetryingOperation<T>
java.lang.Object
com.northconcepts.datapipeline.retry.RetryingOperation<T>
A proxy that attempts to re-run on failure.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCalls the callable, retrying failures with the strategy's delays for up togetMaxRetryCount()attempts in total; rethrows the last exception if none succeeds or the retry predicate declines.longReturns the total number of exceptions/failures seen by this reader.Returns the first exception thrown for any individual read attempt.longReturns the amount of time to wait (in milliseconds) after the first error, before retrying (default 1 second).Returns the last exception thrown for any individual read attempt.longReturns the number of retries allowed across all read attempts (default max long - 1).intReturns the number of retries allowed for any individual read attempt (default 5).Returns the predicate that determines whether to retry after a failure.Returns the retry strategy (defaultRetryStrategy.EXPONENTIAL_BACKOFF).protected voidCalled after each failed attempt; throws once the exception count exceedsgetMaxErrorCount().voidRuns the runnable with the same retry behaviour ascall(Callable).setInitialRetryDelay(long initialRetryDelay) Sets the amount of time to wait (in milliseconds) after the first error, before retrying (default 1 second).setMaxErrorCount(long maxErrorCount) Sets the number of retries allowed across all read attempts (default max long -1).setMaxRetryCount(int maxRetryCount) Sets the number of retries allowed for any individual read attempt (default 5).setRetryPredicate(Predicate<RetryContext> predicate) Sets the predicate that determines whether to retry after a failure.setStrategy(IRetryStrategy strategy) Sets the retry strategy (defaultRetryStrategy.EXPONENTIAL_BACKOFF).
-
Constructor Details
-
RetryingOperation
public RetryingOperation()
-
-
Method Details
-
getMaxRetryCount
public int getMaxRetryCount()Returns the number of retries allowed for any individual read attempt (default 5). -
setMaxRetryCount
Sets the number of retries allowed for any individual read attempt (default 5). -
getMaxErrorCount
public long getMaxErrorCount()Returns the number of retries allowed across all read attempts (default max long - 1). -
setMaxErrorCount
Sets the number of retries allowed across all read attempts (default max long -1). -
getInitialRetryDelay
public long getInitialRetryDelay()Returns the amount of time to wait (in milliseconds) after the first error, before retrying (default 1 second). -
setInitialRetryDelay
Sets the amount of time to wait (in milliseconds) after the first error, before retrying (default 1 second). -
getStrategy
Returns the retry strategy (defaultRetryStrategy.EXPONENTIAL_BACKOFF). -
setStrategy
Sets the retry strategy (defaultRetryStrategy.EXPONENTIAL_BACKOFF). -
getExceptionCount
public long getExceptionCount()Returns the total number of exceptions/failures seen by this reader. This value is also the number of retries as long as maxErrorCount hasn't been exceeded. -
getFirstException
Returns the first exception thrown for any individual read attempt. This value will reset on the next read attempt after a successful retry. -
getLastException
Returns the last exception thrown for any individual read attempt. This value will reset on the next read attempt after a successful retry. -
getRetryPredicate
Returns the predicate that determines whether to retry after a failure. The predicate is passed aRetryContextthat contains information about the retry attempt. By default, the predicate always returns true, meaning that the operation will always retry until maxRetryCount or maxErrorCount is reached. -
setRetryPredicate
Sets the predicate that determines whether to retry after a failure. The predicate is passed aRetryContextthat contains information about the retry attempt. By default, the predicate always returns true, meaning that the operation will always retry until maxRetryCount or maxErrorCount is reached. -
run
Runs the runnable with the same retry behaviour ascall(Callable).- Throws:
Throwable
-
call
Calls the callable, retrying failures with the strategy's delays for up togetMaxRetryCount()attempts in total; rethrows the last exception if none succeeds or the retry predicate declines.- Throws:
Throwable
-
onFailure
Called after each failed attempt; throws once the exception count exceedsgetMaxErrorCount().- Throws:
Throwable
-