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>
final class AsyncExecutionImpl<R> extends ExecutionImpl<R> implements AsyncExecutionInternal<R>
AsyncExecution and AsyncExecutionInternal implementation.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanasyncExecutionprivate FailsafeFuture<R>futureprivate java.util.function.Function<AsyncExecutionInternal<R>,java.util.concurrent.CompletableFuture<ExecutionResult<R>>>outerFnprivate boolean[]policyPostExecutedprivate booleanrecorded-
Fields inherited from class dev.failsafe.ExecutionImpl
attemptRecorded, cancelCallback, cancelledIndex, completed, policyExecutors, result
-
-
Constructor Summary
Constructors Modifier Constructor Description privateAsyncExecutionImpl(AsyncExecutionImpl<R> execution)Create an async execution for a new attempt.(package private)AsyncExecutionImpl(java.util.List<Policy<R>> policies, Scheduler scheduler, FailsafeFuture<R> future, boolean asyncExecution, java.util.function.Function<AsyncExecutionInternal<R>,java.util.concurrent.CompletableFuture<ExecutionResult<R>>> innerFn)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcomplete()Completes the execution and the associatedCompletableFuture.private voidcomplete(ExecutionResult<R> result, java.lang.Throwable error)AsyncExecutionInternal<R>copy()Returns a new copy of the AsyncExecutionInternal.(package private) voidexecuteAsync()Performs an asynchronous execution.booleanisAsyncExecution()Returns whether the execution is an async integration execution.booleanisComplete()Returns whether the execution is complete or if it can be retried.booleanisPostExecuted(int policyIndex)Returns whether the PolicyExecutor corresponding to thepolicyIndexhas already post-executed.booleanisRecorded()Returns whether one of the publicAsyncExecutionrecord or complete methods have been called.voidrecord(R result, java.lang.Throwable exception)Records an executionresultorexceptionwhich triggers failure handling, if needed, by the configured policies.voidrecordException(java.lang.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 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 Detail
-
future
private final FailsafeFuture<R> future
-
asyncExecution
private final boolean asyncExecution
-
outerFn
private java.util.function.Function<AsyncExecutionInternal<R>,java.util.concurrent.CompletableFuture<ExecutionResult<R>>> outerFn
-
policyPostExecuted
private final boolean[] policyPostExecuted
-
recorded
private volatile boolean recorded
-
-
Constructor Detail
-
AsyncExecutionImpl
AsyncExecutionImpl(java.util.List<Policy<R>> policies, Scheduler scheduler, FailsafeFuture<R> future, boolean asyncExecution, java.util.function.Function<AsyncExecutionInternal<R>,java.util.concurrent.CompletableFuture<ExecutionResult<R>>> innerFn)
-
AsyncExecutionImpl
private AsyncExecutionImpl(AsyncExecutionImpl<R> execution)
Create an async execution for a new attempt.
-
-
Method Detail
-
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
public void record(R result, java.lang.Throwable exception)
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
public void recordResult(R result)
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
public void recordException(java.lang.Throwable exception)
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
public AsyncExecutionInternal<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
private void complete(ExecutionResult<R> result, java.lang.Throwable error)
-
-