public final class AsyncExecution extends ExecutionContext
RetryPolicy.| Modifier and Type | Method and Description |
|---|---|
void |
complete()
Completes the execution and the associated
FutureResult. |
boolean |
complete(Object result)
Attempts to complete the execution and the associated
FutureResult with the result. |
boolean |
complete(Object result,
Throwable failure)
Attempts to complete the execution and the associated
FutureResult with the result and
failure. |
<T extends Throwable> |
getLastFailure()
Returns the last failure that was recorded.
|
<T> T |
getLastResult()
Returns the last result that was recorded.
|
Duration |
getWaitTime()
Returns the time to wait before the next execution attempt.
|
boolean |
isComplete()
Returns whether the execution is complete.
|
boolean |
retry()
Records an execution and returns true if a retry has been scheduled for else returns returns false and completes
the execution and associated
FutureResult. |
boolean |
retryFor(Object result)
Records an execution and returns true if a retry has been scheduled for the
result, else returns false and
marks the execution and associated FutureResult as complete. |
boolean |
retryFor(Object result,
Throwable failure)
Records an execution and returns true if a retry has been scheduled for the
result or failure, else
returns false and marks the execution and associated FutureResult as complete. |
boolean |
retryOn(Throwable failure)
Records an execution and returns true if a retry has been scheduled for the
failure, else returns false and
marks the execution and associated FutureResult as complete. |
getElapsedTime, getExecutions, getStartTimepublic void complete()
FutureResult.IllegalStateException - if the execution is already completepublic boolean complete(Object result)
FutureResult with the result. Returns true on
success, else false if completion failed and the execution should be retried via retry().IllegalStateException - if the execution is already completepublic boolean complete(Object result, Throwable failure)
FutureResult with the result and
failure. Returns true on success, else false if completion failed and the execution should be retried via
retry().
Note: the execution may be completed even when the failure is not null, such as when the
RetryPolicy does not allow retries for the failure.
IllegalStateException - if the execution is already completepublic boolean retry()
FutureResult.IllegalStateException - if a retry method has already been called or the execution is already completepublic boolean retryFor(Object result)
result, else returns false and
marks the execution and associated FutureResult as complete.IllegalStateException - if a retry method has already been called or the execution is already completepublic boolean retryFor(Object result, Throwable failure)
result or failure, else
returns false and marks the execution and associated FutureResult as complete.IllegalStateException - if a retry method has already been called or the execution is already completepublic boolean retryOn(Throwable failure)
failure, else returns false and
marks the execution and associated FutureResult as complete.NullPointerException - if failure is nullIllegalStateException - if a retry method has already been called or the execution is already completepublic <T extends Throwable> T getLastFailure()
public <T> T getLastResult()
public Duration getWaitTime()
0 if an execution has not yet occurred.public boolean isComplete()
Copyright © 2018. All rights reserved.