public class Invocation extends Object
RetryPolicy.| Modifier and Type | Field and Description |
|---|---|
protected boolean |
completed |
protected Throwable |
lastFailure |
protected Object |
lastResult |
| Constructor and Description |
|---|
Invocation(RetryPolicy retryPolicy) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canRetryFor(Object result)
Returns true if a retry can be performed for the
result, else returns false and completes the invocation. |
boolean |
canRetryFor(Object result,
Throwable failure)
Returns true if a retry can be performed for the
result or failure, else returns false and
completes the invocation. |
boolean |
canRetryOn(Throwable failure)
Returns true if a retry can be performed for the
failure, else returns false and completes the invocation. |
void |
complete()
Completes the invocation.
|
boolean |
complete(Object result)
Returns true if a retry can be performed for the
result or failure, else returns false and records
and completes the invocation. |
int |
getAttemptCount()
Gets the number of invocation attempts so far.
|
<T extends Throwable> |
getLastFailure()
Returns the last failure that was recorded.
|
<T> T |
getLastResult()
Returns the last result that was recorded.
|
long |
getWaitTime()
Returns the wait time in nanoseconds.
|
boolean |
isComplete()
Returns whether the invocation is complete.
|
boolean |
recordFailure(Throwable failure)
Records a failed invocation attempt and returns true if a retry can be performed for the
failure, else
returns false and completes the invocation. |
protected volatile Object lastResult
protected volatile Throwable lastFailure
protected volatile boolean completed
public Invocation(RetryPolicy retryPolicy)
public boolean canRetryFor(Object result)
result, else returns false and completes the invocation.IllegalStateException - if the invocation is already completepublic boolean canRetryFor(Object result, Throwable failure)
result or failure, else returns false and
completes the invocation.IllegalStateException - if the invocation is already completepublic boolean canRetryOn(Throwable failure)
failure, else returns false and completes the invocation.IllegalStateException - if the invocation is already completepublic void complete()
IllegalStateException - if the invocation is already completepublic boolean complete(Object result)
result or failure, else returns false and records
and completes the invocation.IllegalStateException - if the invocation is already completepublic int getAttemptCount()
canRetry is called or
when the invocation is completed successfully.public <T extends Throwable> T getLastFailure()
recordFailure(Throwable)public <T> T getLastResult()
complete(),
complete(Object)public long getWaitTime()
public boolean isComplete()
complete(),
complete(Object),
recordFailure(Throwable)public boolean recordFailure(Throwable failure)
failure, else
returns false and completes the invocation.
Alias of canRetryOn(Throwable)
IllegalStateException - if the invocation is already completeCopyright © 2015. All Rights Reserved.