Retryable
, org.refcodes.mixin.Abortable
, org.refcodes.mixin.ReadTimeoutInMsAccessor
, org.refcodes.mixin.Restartable
public class RetryTimeout extends Object implements Retryable, org.refcodes.mixin.ReadTimeoutInMsAccessor
RetryTimeout
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 nextRetry()
till the last call to nextRetry()
. Any
delay inside the iteration loop is not added up to the delay.
org.refcodes.mixin.ReadTimeoutInMsAccessor.ReadTimeoutInMsBuilder<B extends org.refcodes.mixin.ReadTimeoutInMsAccessor.ReadTimeoutInMsBuilder<B>>, org.refcodes.mixin.ReadTimeoutInMsAccessor.ReadTimeoutInMsMutator, org.refcodes.mixin.ReadTimeoutInMsAccessor.ReadTimeoutInMsProperty
Constructor | Description |
---|---|
RetryTimeout(long aTimeoutInMs,
int aRetryLoops) |
Constructs the
RetryTimeout with the given timeout and the given
number of retry loops. |
RetryTimeout(long aTimeoutInMs,
long aRetryDelayInMs) |
Constructs the
RetryTimeout with the given timeout and the given
retry delay. |
Modifier and Type | Method | Description |
---|---|---|
void |
abort() |
|
long |
getReadTimeoutInMs() |
Returns the timeout altogether the
RetryTimeout is waiting while
iterating through the RetryTimeout via hasNextRetry()
and nextRetry() . |
int |
getRetryCount() |
The current state regarding the retires.
|
long |
getRetryDelayInMs() |
Returns retry to wait in milliseconds upon calling
nextRetry() ). |
boolean |
hasNextRetry() |
Returns true in case not all retires have been used up.
|
boolean |
nextRetry() |
Tests whether a next retry is possible.
|
boolean |
nextRetry(Object aMonitor) |
Tests whether a next retry is possible.
|
void |
restart() |
public RetryTimeout(long aTimeoutInMs, long aRetryDelayInMs)
RetryTimeout
with the given timeout and the given
retry delay. The retry number is round about:
-------------------------------------------------------------------------
"aTimeoutInMs / aRetryDelayInMs"
-------------------------------------------------------------------------
CAUTION: The above mentioned is not necessarily so, in case your business
logic inside the loop iterations is slow, then less retries fit in the
given timeout.aTimeoutInMs
- The total time in milliseconds all iterations
together will delay.aRetryDelayInMs
- The delay before each retry to wait in
milliseconds.public RetryTimeout(long aTimeoutInMs, int aRetryLoops)
RetryTimeout
with the given timeout and the given
number of retry loops. The retry delay is round about:
-------------------------------------------------------------------------
"aTimeoutInMs / aRetryLoops"
-------------------------------------------------------------------------
CAUTION: The above mentioned is not necessarily so, in case your business
logic inside the loop iterations is slow, then less retries fit in the
given timeout.aTimeoutInMs
- The total time in milliseconds all iterations
together will delay.aRetryLoops
- The number of retries, each retry delay before each
retry to wait in milliseconds is about the timeout divided by the
retry number.public boolean nextRetry()
Object.notify()
or Object.notifyAll()
. Similar to the
nextRetry()
with the difference of accepting a dedicated monitor
which is used for aborting the dellay.nextRetry
in interface Retryable
hasNextRetry()
.public boolean nextRetry(Object aMonitor)
Object.notify()
or Object.notifyAll()
. Similar to the
nextRetry()
with the difference of accepting a dedicated monitor
which is used for aborting the dellay.aMonitor
- the monitorhasNextRetry()
.public boolean hasNextRetry()
hasNextRetry
in interface Retryable
public int getRetryCount()
getRetryCount
in interface Retryable
public void abort()
abort
in interface org.refcodes.mixin.Abortable
public void restart()
restart
in interface org.refcodes.mixin.Restartable
public long getReadTimeoutInMs()
RetryTimeout
is waiting while
iterating through the RetryTimeout
via hasNextRetry()
and nextRetry()
. The actual timeout being waited is the
effective time elapsed from the first call to nextRetry()
till
the last call to nextRetry()
. Any delay inside the iteration
loop is not added up to the delay.getReadTimeoutInMs
in interface org.refcodes.mixin.ReadTimeoutInMsAccessor
public long getRetryDelayInMs()
nextRetry()
).Copyright © 2021. All rights reserved.