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 booleanprivate final FailsafeFuture<R> private Function<AsyncExecutionInternal<R>, CompletableFuture<ExecutionResult<R>>> private final boolean[]private booleanFields inherited from class ExecutionImpl
attemptRecorded, cancelCallback, cancelledIndex, completed, policyExecutors, result -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateAsyncExecutionImpl(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 TypeMethodDescriptionvoidcomplete()Completes the execution and the associatedCompletableFuture.private voidcomplete(ExecutionResult<R> result, Throwable error) copy()Returns a new copy of the AsyncExecutionInternal.(package private) voidPerforms an asynchronous execution.booleanReturns whether the execution is an async integration execution.booleanReturns whether the execution is complete or if it can be retried.booleanisPostExecuted(int policyIndex) Returns whether the PolicyExecutor corresponding to thepolicyIndexhas already post-executed.booleanReturns whether one of the publicAsyncExecutionrecord or complete methods have been called.voidRecords an executionresultorexceptionwhich triggers failure handling, if needed, by the configured policies.voidrecordException(Throwable exception) Records anexceptionwhich triggers failure handling, if needed, by the configured policies.voidrecordResult(R result) Records an executionresultwhich triggers failure handling, if needed, by the configured policies.voidsetPostExecuted(int policyIndex) Sets the PolicyExecutor corresponding to thepolicyIndexas having post-executed.Methods inherited from class ExecutionImpl
cancel, cancel, getAttemptCount, getElapsedAttemptTime, getElapsedTime, getExecutionCount, getLastException, getLastResult, getLastResult, getLatest, getLock, getResult, getStartTime, isCancelled, isCancelled, isFirstAttempt, isPreExecuted, isRetry, onCancel, postExecute, preExecute, record, recordAttempt, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ExecutionContext
getAttemptCount, getElapsedAttemptTime, getElapsedTime, getExecutionCount, getLastException, getLastResult, getLastResult, getStartTime, isCancelled, isFirstAttempt, isRetry, onCancelMethods inherited from interface 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:AsyncExecutionCompletes the execution and the associatedCompletableFuture.- Specified by:
completein interfaceAsyncExecution<R>
-
isComplete
public boolean isComplete()Description copied from interface:AsyncExecutionReturns 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:
isCompletein interfaceAsyncExecution<R>
-
record
Description copied from interface:AsyncExecutionRecords an executionresultorexceptionwhich triggers failure handling, if needed, by the configured policies. If policy handling is not possible or already complete, the resultingCompletableFutureis completed.- Specified by:
recordin interfaceAsyncExecution<R>
-
recordResult
Description copied from interface:AsyncExecutionRecords an executionresultwhich triggers failure handling, if needed, by the configured policies. If policy handling is not possible or already complete, the resultingCompletableFutureis completed.- Specified by:
recordResultin interfaceAsyncExecution<R>
-
recordException
Description copied from interface:AsyncExecutionRecords anexceptionwhich triggers failure handling, if needed, by the configured policies. If policy handling is not possible or already complete, the resultingCompletableFutureis completed.- Specified by:
recordExceptionin interfaceAsyncExecution<R>
-
isAsyncExecution
public boolean isAsyncExecution()Description copied from interface:AsyncExecutionInternalReturns whether the execution is an async integration execution.- Specified by:
isAsyncExecutionin interfaceAsyncExecutionInternal<R>
-
isRecorded
public boolean isRecorded()Description copied from interface:AsyncExecutionInternalReturns whether one of the publicAsyncExecutionrecord or complete methods have been called.- Specified by:
isRecordedin interfaceAsyncExecutionInternal<R>
-
setPostExecuted
public void setPostExecuted(int policyIndex) Description copied from interface:AsyncExecutionInternalSets the PolicyExecutor corresponding to thepolicyIndexas having post-executed.- Specified by:
setPostExecutedin interfaceAsyncExecutionInternal<R>
-
isPostExecuted
public boolean isPostExecuted(int policyIndex) Description copied from interface:AsyncExecutionInternalReturns whether the PolicyExecutor corresponding to thepolicyIndexhas already post-executed.- Specified by:
isPostExecutedin interfaceAsyncExecutionInternal<R>
-
copy
Description copied from interface:AsyncExecutionInternalReturns a new copy of the AsyncExecutionInternal.- Specified by:
copyin interfaceAsyncExecutionInternal<R>
-
executeAsync
void executeAsync()Performs an asynchronous execution. -
complete
-