Package org.refcodes.controlflow
Interface RetryTimeout
-
- All Superinterfaces:
org.refcodes.mixin.Abortable
,org.refcodes.mixin.Restartable
,Retryable
- All Known Implementing Classes:
RetryTimeoutImpl
public interface RetryTimeout extends Retryable
TheRetryTimeout
can be used in loops to test whether a timeout has been reached, if the timeout has not been reached, then a given period of time (delay) is waited. In case no more timeout is "left" the business logic may act accordingly such as throwing an exception.The actual timeout being waited is the effective time elapsed from the first call to
Retryable.nextRetry()
till the last call toRetryable.nextRetry()
. Any delay inside the iteration loop is not added up to the delay.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description long
getRetryDelayInMs()
Returns retry to wait in milliseconds upon callingRetryable.nextRetry()
).long
getTimeoutInMs()
Returns the timeout altogether theRetryTimeout
is waiting while iterating through theRetryTimeout
viaRetryable.hasNextRetry()
andRetryable.nextRetry()
.boolean
nextRetry(java.lang.Object aMonitor)
Tests whether a next retry is possible.-
Methods inherited from interface org.refcodes.controlflow.Retryable
getRetryCount, hasNextRetry, nextRetry
-
-
-
-
Method Detail
-
nextRetry
boolean nextRetry(java.lang.Object aMonitor)
Tests whether a next retry is possible. In case this is the case, then the thread is delayed by the configured (implementation specific) delay time or until the provided monitor is notified viaObject.notify()
orObject.notifyAll()
. Similar to theRetryable.nextRetry()
with the difference of accepting a dedicated monitor which is used for aborting the dellay.- Parameters:
aMonitor
- the monitor- Returns:
- True in case there is a next retry as of
Retryable.hasNextRetry()
.
-
getTimeoutInMs
long getTimeoutInMs()
Returns the timeout altogether theRetryTimeout
is waiting while iterating through theRetryTimeout
viaRetryable.hasNextRetry()
andRetryable.nextRetry()
. The actual timeout being waited is the effective time elapsed from the first call toRetryable.nextRetry()
till the last call toRetryable.nextRetry()
. Any delay inside the iteration loop is not added up to the delay.- Returns:
- The
-
getRetryDelayInMs
long getRetryDelayInMs()
Returns retry to wait in milliseconds upon callingRetryable.nextRetry()
).- Returns:
- The delay being set in milliseconds.
-
-