Package dev.failsafe

Class SyncExecutionImpl<R>

    • Field Detail

      • executionThread

        private final java.lang.Thread executionThread
      • interruptable

        private final java.util.concurrent.atomic.AtomicBoolean interruptable
      • interrupted

        private final java.util.concurrent.atomic.AtomicBoolean interrupted
      • delayNanos

        private volatile long delayNanos
    • Constructor Detail

      • SyncExecutionImpl

        SyncExecutionImpl​(java.util.List<? extends Policy<R>> policies)
        Create a standalone sync execution for the policies.
      • SyncExecutionImpl

        private SyncExecutionImpl​(SyncExecutionImpl<R> execution)
        Create a sync execution for a new attempt.
    • Method Detail

      • complete

        public void complete()
        Description copied from interface: Execution
        Records and completes the execution successfully.
        Specified by:
        complete in interface Execution<R>
      • isComplete

        public boolean isComplete()
        Description copied from interface: Execution
        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 interface Execution<R>
      • getDelay

        public java.time.Duration getDelay()
        Description copied from interface: Execution
        Returns the time to delay before the next execution attempt. Returns 0 if an execution has not yet occurred.
        Specified by:
        getDelay in interface Execution<R>
      • record

        public void record​(R result,
                           java.lang.Throwable exception)
        Description copied from interface: Execution
        Records an execution result or exception which triggers failure handling, if needed, by the configured policies. If policy handling is not possible or completed, the execution is completed.
        Specified by:
        record in interface Execution<R>
      • recordResult

        public void recordResult​(R result)
        Description copied from interface: Execution
        Records an execution result which triggers failure handling, if needed, by the configured policies. If policy handling is not possible or completed, the execution is completed.
        Specified by:
        recordResult in interface Execution<R>
      • recordException

        public void recordException​(java.lang.Throwable exception)
        Description copied from interface: Execution
        Records an exception which triggers failure handling, if needed, by the configured policies. If policy handling is not possible or completed, the execution is completed.
        Specified by:
        recordException in interface Execution<R>
      • postExecute

        ExecutionResult<R> postExecute​(ExecutionResult<R> result)
        Description copied from class: ExecutionImpl
        Externally called. Records an execution and performs post-execution handling for the result against all configured policy executors. Returns whether the result is complete for all policies.
        Overrides:
        postExecute in class ExecutionImpl<R>
      • isStandalone

        private boolean isStandalone()
      • copy

        public SyncExecutionImpl<R> copy()
        Description copied from interface: SyncExecutionInternal
        Returns a new copy of the SyncExecutionInternal if it is not standalone, else returns this since standalone executions are referenced externally and cannot be replaced.
        Specified by:
        copy in interface SyncExecutionInternal<R>
      • executeSync

        R executeSync()
        Performs a synchronous execution.