Package dev.failsafe
Class AsyncExecutionImpl<R>
java.lang.Object
dev.failsafe.ExecutionImpl<R>
dev.failsafe.AsyncExecutionImpl<R>
- Type Parameters:
R
- result type
- All Implemented Interfaces:
AsyncExecution<R>
,ExecutionContext<R>
,AsyncExecutionInternal<R>
,ExecutionInternal<R>
AsyncExecution and AsyncExecutionInternal implementation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private final FailsafeFuture
<R> private Function
<AsyncExecutionInternal<R>, CompletableFuture<ExecutionResult<R>>> private final boolean[]
private boolean
Fields inherited from class dev.failsafe.ExecutionImpl
attemptRecorded, cancelCallback, cancelledIndex, completed, policyExecutors, result
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
AsyncExecutionImpl
(AsyncExecutionImpl<R> execution) Create an async execution for a new attempt.(package private)
AsyncExecutionImpl
(List<Policy<R>> policies, Scheduler scheduler, FailsafeFuture<R> future, boolean asyncExecution, Function<AsyncExecutionInternal<R>, CompletableFuture<ExecutionResult<R>>> innerFn) -
Method Summary
Modifier and TypeMethodDescriptionvoid
complete()
Completes the execution and the associatedCompletableFuture
.private void
complete
(ExecutionResult<R> result, Throwable error) copy()
Returns a new copy of the AsyncExecutionInternal.(package private) void
Performs an asynchronous execution.boolean
Returns whether the execution is an async integration execution.boolean
Returns whether the execution is complete or if it can be retried.boolean
isPostExecuted
(int policyIndex) Returns whether the PolicyExecutor corresponding to thepolicyIndex
has already post-executed.boolean
Returns whether one of the publicAsyncExecution
record or complete methods have been called.void
Records an executionresult
orexception
which triggers failure handling, if needed, by the configured policies.void
recordException
(Throwable exception) Records anexception
which triggers failure handling, if needed, by the configured policies.void
recordResult
(R result) Records an executionresult
which triggers failure handling, if needed, by the configured policies.void
setPostExecuted
(int policyIndex) Sets the PolicyExecutor corresponding to thepolicyIndex
as having post-executed.Methods inherited from class dev.failsafe.ExecutionImpl
cancel, cancel, getAttemptCount, getElapsedAttemptTime, getElapsedTime, getExecutionCount, getLastException, getLastResult, getLastResult, getLatest, getLock, getResult, getStartTime, isCancelled, isCancelled, isFirstAttempt, isPreExecuted, isRetry, onCancel, postExecute, preExecute, record, recordAttempt, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface dev.failsafe.ExecutionContext
getAttemptCount, getElapsedAttemptTime, getElapsedTime, getExecutionCount, getLastException, getLastResult, getLastResult, getStartTime, isCancelled, isFirstAttempt, isRetry, onCancel
Methods inherited from interface dev.failsafe.spi.ExecutionInternal
cancel, cancel, getLatest, getLock, getResult, isCancelled, isPreExecuted, preExecute, record, recordAttempt
-
Field Details
-
future
-
asyncExecution
private final boolean asyncExecution -
outerFn
-
policyPostExecuted
private final boolean[] policyPostExecuted -
recorded
private volatile boolean recorded
-
-
Constructor Details
-
AsyncExecutionImpl
AsyncExecutionImpl(List<Policy<R>> policies, Scheduler scheduler, FailsafeFuture<R> future, boolean asyncExecution, Function<AsyncExecutionInternal<R>, CompletableFuture<ExecutionResult<R>>> innerFn) -
AsyncExecutionImpl
Create an async execution for a new attempt.
-
-
Method Details
-
complete
public void complete()Description copied from interface:AsyncExecution
Completes the execution and the associatedCompletableFuture
.- Specified by:
complete
in interfaceAsyncExecution<R>
-
isComplete
public boolean isComplete()Description copied from interface:AsyncExecution
Returns whether the execution is complete or if it can be retried. An execution is considered complete only when all configured policies consider the execution complete.- Specified by:
isComplete
in interfaceAsyncExecution<R>
-
record
Description copied from interface:AsyncExecution
Records an executionresult
orexception
which triggers failure handling, if needed, by the configured policies. If policy handling is not possible or already complete, the resultingCompletableFuture
is completed.- Specified by:
record
in interfaceAsyncExecution<R>
-
recordResult
Description copied from interface:AsyncExecution
Records an executionresult
which triggers failure handling, if needed, by the configured policies. If policy handling is not possible or already complete, the resultingCompletableFuture
is completed.- Specified by:
recordResult
in interfaceAsyncExecution<R>
-
recordException
Description copied from interface:AsyncExecution
Records anexception
which triggers failure handling, if needed, by the configured policies. If policy handling is not possible or already complete, the resultingCompletableFuture
is completed.- Specified by:
recordException
in interfaceAsyncExecution<R>
-
isAsyncExecution
public boolean isAsyncExecution()Description copied from interface:AsyncExecutionInternal
Returns whether the execution is an async integration execution.- Specified by:
isAsyncExecution
in interfaceAsyncExecutionInternal<R>
-
isRecorded
public boolean isRecorded()Description copied from interface:AsyncExecutionInternal
Returns whether one of the publicAsyncExecution
record or complete methods have been called.- Specified by:
isRecorded
in interfaceAsyncExecutionInternal<R>
-
setPostExecuted
public void setPostExecuted(int policyIndex) Description copied from interface:AsyncExecutionInternal
Sets the PolicyExecutor corresponding to thepolicyIndex
as having post-executed.- Specified by:
setPostExecuted
in interfaceAsyncExecutionInternal<R>
-
isPostExecuted
public boolean isPostExecuted(int policyIndex) Description copied from interface:AsyncExecutionInternal
Returns whether the PolicyExecutor corresponding to thepolicyIndex
has already post-executed.- Specified by:
isPostExecuted
in interfaceAsyncExecutionInternal<R>
-
copy
Description copied from interface:AsyncExecutionInternal
Returns a new copy of the AsyncExecutionInternal.- Specified by:
copy
in interfaceAsyncExecutionInternal<R>
-
executeAsync
void executeAsync()Performs an asynchronous execution. -
complete
-