public class RetryTimeoutImpl extends Object implements RetryTimeout
RetryTimeout
interface.Constructor and Description |
---|
RetryTimeoutImpl(long aTimeoutInMs,
int aRetryLoops)
Constructs the
RetryTimeoutImpl with the given timeout and the
given number of retry loops. |
RetryTimeoutImpl(long aTimeoutInMs,
long aRetryDelayInMs)
Constructs the
RetryTimeoutImpl with the given timeout and the
given retry delay. |
Modifier and Type | Method and Description |
---|---|
void |
abort() |
int |
getRetryCount()
The current state regarding the retires.
|
long |
getRetryDelayInMs()
Returns retry to wait in milliseconds upon calling
Retryable.nextRetry() ). |
long |
getTimeoutInMs()
Returns the timeout altogether the
RetryTimeout is waiting while
iterating through the RetryTimeout via Retryable.hasNextRetry()
and Retryable.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 RetryTimeoutImpl(long aTimeoutInMs, long aRetryDelayInMs)
RetryTimeoutImpl
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 RetryTimeoutImpl(long aTimeoutInMs, int aRetryLoops)
RetryTimeoutImpl
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()
nextRetry
in interface Retryable
Retryable.hasNextRetry()
.public boolean nextRetry(Object aMonitor)
Object.notify()
or Object.notifyAll()
. Similar to the
Retryable.nextRetry()
with the difference of accepting a dedicated monitor
which is used for aborting the dellay.nextRetry
in interface RetryTimeout
aMonitor
- the a monitorRetryable.hasNextRetry()
.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 getTimeoutInMs()
RetryTimeout
is waiting while
iterating through the RetryTimeout
via Retryable.hasNextRetry()
and Retryable.nextRetry()
. The actual timeout being waited is the
effective time elapsed from the first call to Retryable.nextRetry()
till
the last call to Retryable.nextRetry()
. Any delay inside the iteration
loop is not added up to the delay.getTimeoutInMs
in interface RetryTimeout
public long getRetryDelayInMs()
Retryable.nextRetry()
).getRetryDelayInMs
in interface RetryTimeout
Copyright © 2018. All rights reserved.