public class Invocation extends Object implements InvocationStats
RetryPolicy.| Modifier and Type | Field and Description |
|---|---|
protected boolean |
completed |
protected Throwable |
lastFailure |
protected Object |
lastResult |
| Constructor and Description |
|---|
Invocation(RetryPolicy retryPolicy)
Creates a new Invocation for the
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)
Attempts to complete the invocation with the
result. |
int |
getAttemptCount()
Gets the number of invocation attempts so far.
|
long |
getElapsedMillis()
Returns the elapsed time in milliseconds.
|
long |
getElapsedNanos()
Returns the elapsed time in nanoseconds.
|
<T extends Throwable> |
getLastFailure()
Returns the last failure that was recorded.
|
<T> T |
getLastResult()
Returns the last result that was recorded.
|
long |
getStartMillis()
Returns the start time in milliseconds.
|
long |
getStartNanos()
Returns the start time in nanoseconds.
|
long |
getWaitMillis()
Returns the wait time in milliseconds.
|
long |
getWaitNanos()
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)
retryPolicy.NullPointerException - if retryPolicy is nullpublic 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.NullPointerException - if failure is nullIllegalStateException - if the invocation is already completepublic void complete()
IllegalStateException - if the invocation is already completepublic boolean complete(Object result)
result. Returns true on success, else false if completion
failed and should be retried.IllegalStateException - if the invocation is already completepublic int getAttemptCount()
canRetry is called or
when the invocation is completed successfully.getAttemptCount in interface InvocationStatspublic long getElapsedMillis()
getElapsedMillis in interface InvocationStatspublic long getElapsedNanos()
getElapsedNanos in interface InvocationStatspublic <T extends Throwable> T getLastFailure()
recordFailure(Throwable)public <T> T getLastResult()
complete(),
complete(Object)public long getStartMillis()
getStartMillis in interface InvocationStatspublic long getStartNanos()
getStartNanos in interface InvocationStatspublic long getWaitMillis()
public long getWaitNanos()
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 © 2016. All Rights Reserved.