Class FaultToleranceCommand

  • All Implemented Interfaces:
    com.netflix.hystrix.HystrixExecutable<Object>, com.netflix.hystrix.HystrixInvokable<Object>, com.netflix.hystrix.HystrixInvokableInfo<Object>, com.netflix.hystrix.HystrixObservable<Object>

    public class FaultToleranceCommand
    extends com.netflix.hystrix.HystrixCommand<Object>
    Class FaultToleranceCommand.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.netflix.hystrix.HystrixCommand

        com.netflix.hystrix.HystrixCommand.Setter
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected com.netflix.hystrix.HystrixCircuitBreaker circuitBreaker  
      protected static ConcurrentHashMap<com.netflix.hystrix.HystrixCommandKey,​Boolean> commandContainsFallback  
      protected com.netflix.hystrix.HystrixCommandGroupKey commandGroup  
      protected long commandStartTimestamp  
      protected AtomicReference<com.netflix.hystrix.AbstractCommand.CommandState> commandState  
      protected com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy concurrencyStrategy  
      protected com.netflix.hystrix.HystrixRequestLog currentRequestLog  
      protected rx.functions.Action0 endCurrentThreadExecutingCommand  
      protected com.netflix.hystrix.strategy.eventnotifier.HystrixEventNotifier eventNotifier  
      protected com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook executionHook  
      protected com.netflix.hystrix.ExecutionResult executionResult  
      protected com.netflix.hystrix.ExecutionResult executionResultAtTimeOfCancellation  
      protected com.netflix.hystrix.AbstractCommand.TryableSemaphore executionSemaphoreOverride  
      protected static ConcurrentHashMap<String,​com.netflix.hystrix.AbstractCommand.TryableSemaphore> executionSemaphorePerCircuit  
      protected com.netflix.hystrix.AbstractCommand.TryableSemaphore fallbackSemaphoreOverride  
      protected static ConcurrentHashMap<String,​com.netflix.hystrix.AbstractCommand.TryableSemaphore> fallbackSemaphorePerCircuit  
      protected AtomicReference<com.netflix.hystrix.AbstractCommand.TimedOutStatus> isCommandTimedOut  
      protected boolean isResponseFromCache  
      protected com.netflix.hystrix.HystrixCommandMetrics metrics  
      protected com.netflix.hystrix.HystrixCommandProperties properties  
      protected com.netflix.hystrix.HystrixRequestCache requestCache  
      protected com.netflix.hystrix.HystrixThreadPool threadPool  
      protected com.netflix.hystrix.HystrixThreadPoolKey threadPoolKey  
      protected AtomicReference<com.netflix.hystrix.AbstractCommand.ThreadState> threadState  
      protected AtomicReference<Reference<com.netflix.hystrix.util.HystrixTimer.TimerListener>> timeoutTimer  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected Throwable decomposeException​(Exception arg0)  
      Object execute()
      Executes this command returning a result or throwing an exception.
      protected String getCacheKey()  
      com.netflix.hystrix.HystrixCommandGroupKey getCommandGroup()  
      com.netflix.hystrix.HystrixCommandKey getCommandKey()  
      long getCommandRunStartTimeInNanos()  
      com.netflix.hystrix.ExecutionResult.EventCounts getEventCounts()  
      protected Exception getExceptionFromThrowable​(Throwable arg0)  
      List<com.netflix.hystrix.HystrixEventType> getExecutionEvents()  
      Throwable getExecutionException()  
      protected com.netflix.hystrix.AbstractCommand.TryableSemaphore getExecutionSemaphore()  
      int getExecutionTimeInMilliseconds()  
      Throwable getFailedExecutionException()  
      protected com.netflix.hystrix.AbstractCommand.TryableSemaphore getFallbackSemaphore()  
      protected String getLogMessagePrefix()  
      com.netflix.hystrix.HystrixCommandMetrics getMetrics()  
      int getNumberCollapsed()  
      int getNumberEmissions()  
      int getNumberFallbackEmissions()  
      com.netflix.hystrix.HystrixCollapserKey getOriginatingCollapserKey()  
      com.netflix.hystrix.HystrixCommandProperties getProperties()  
      String getPublicCacheKey()  
      com.netflix.hystrix.HystrixThreadPoolKey getThreadPoolKey()  
      protected void handleThreadEnd​(com.netflix.hystrix.AbstractCommand<R> arg0)  
      boolean isCircuitBreakerOpen()  
      boolean isExecutedInThread()  
      boolean isExecutionComplete()  
      boolean isFailedExecution()  
      protected boolean isRequestCachingEnabled()  
      boolean isResponseFromCache()  
      boolean isResponseFromFallback()  
      boolean isResponseRejected()  
      boolean isResponseSemaphoreRejected()  
      boolean isResponseShortCircuited()  
      boolean isResponseThreadPoolRejected()  
      boolean isResponseTimedOut()  
      boolean isSuccessfulExecution()  
      rx.Observable<R> observe()  
      Object run()
      Code to run as part of this command.
      protected boolean shouldNotBeWrapped​(Throwable arg0)  
      protected boolean shouldOutputOnNextEvents()  
      rx.Observable<R> toObservable()  
      • Methods inherited from class com.netflix.hystrix.HystrixCommand

        commandIsScalar, getExecutionObservable, getFallback, getFallbackMethodName, getFallbackObservable, isFallbackUserDefined, queue
      • Methods inherited from interface com.netflix.hystrix.HystrixExecutable

        observe
      • Methods inherited from interface com.netflix.hystrix.HystrixInvokableInfo

        getCommandGroup, getCommandKey, getCommandRunStartTimeInNanos, getEventCounts, getExecutionEvents, getExecutionTimeInMilliseconds, getFailedExecutionException, getMetrics, getNumberCollapsed, getNumberEmissions, getNumberFallbackEmissions, getOriginatingCollapserKey, getProperties, getPublicCacheKey, getThreadPoolKey, isCircuitBreakerOpen, isExecutedInThread, isExecutionComplete, isFailedExecution, isResponseFromCache, isResponseFromFallback, isResponseRejected, isResponseSemaphoreRejected, isResponseShortCircuited, isResponseThreadPoolRejected, isResponseTimedOut, isSuccessfulExecution
      • Methods inherited from interface com.netflix.hystrix.HystrixObservable

        observe, toObservable
    • Field Detail

      • circuitBreaker

        protected final com.netflix.hystrix.HystrixCircuitBreaker circuitBreaker
      • threadPool

        protected final com.netflix.hystrix.HystrixThreadPool threadPool
      • threadPoolKey

        protected final com.netflix.hystrix.HystrixThreadPoolKey threadPoolKey
      • properties

        protected final com.netflix.hystrix.HystrixCommandProperties properties
      • metrics

        protected final com.netflix.hystrix.HystrixCommandMetrics metrics
      • commandGroup

        protected final com.netflix.hystrix.HystrixCommandGroupKey commandGroup
      • eventNotifier

        protected final com.netflix.hystrix.strategy.eventnotifier.HystrixEventNotifier eventNotifier
      • concurrencyStrategy

        protected final com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy concurrencyStrategy
      • executionHook

        protected final com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook executionHook
      • fallbackSemaphoreOverride

        protected final com.netflix.hystrix.AbstractCommand.TryableSemaphore fallbackSemaphoreOverride
      • fallbackSemaphorePerCircuit

        protected static final ConcurrentHashMap<String,​com.netflix.hystrix.AbstractCommand.TryableSemaphore> fallbackSemaphorePerCircuit
      • executionSemaphoreOverride

        protected final com.netflix.hystrix.AbstractCommand.TryableSemaphore executionSemaphoreOverride
      • executionSemaphorePerCircuit

        protected static final ConcurrentHashMap<String,​com.netflix.hystrix.AbstractCommand.TryableSemaphore> executionSemaphorePerCircuit
      • timeoutTimer

        protected final AtomicReference<Reference<com.netflix.hystrix.util.HystrixTimer.TimerListener>> timeoutTimer
      • commandState

        protected AtomicReference<com.netflix.hystrix.AbstractCommand.CommandState> commandState
      • threadState

        protected AtomicReference<com.netflix.hystrix.AbstractCommand.ThreadState> threadState
      • executionResult

        protected volatile com.netflix.hystrix.ExecutionResult executionResult
      • isResponseFromCache

        protected volatile boolean isResponseFromCache
      • executionResultAtTimeOfCancellation

        protected volatile com.netflix.hystrix.ExecutionResult executionResultAtTimeOfCancellation
      • commandStartTimestamp

        protected volatile long commandStartTimestamp
      • isCommandTimedOut

        protected final AtomicReference<com.netflix.hystrix.AbstractCommand.TimedOutStatus> isCommandTimedOut
      • endCurrentThreadExecutingCommand

        protected volatile rx.functions.Action0 endCurrentThreadExecutingCommand
      • requestCache

        protected final com.netflix.hystrix.HystrixRequestCache requestCache
      • currentRequestLog

        protected final com.netflix.hystrix.HystrixRequestLog currentRequestLog
      • commandContainsFallback

        protected static ConcurrentHashMap<com.netflix.hystrix.HystrixCommandKey,​Boolean> commandContainsFallback
    • Constructor Detail

      • FaultToleranceCommand

        public FaultToleranceCommand​(CommandRetrier commandRetrier,
                                     String commandKey,
                                     io.helidon.microprofile.faulttolerance.MethodIntrospector introspector,
                                     javax.interceptor.InvocationContext context,
                                     ClassLoader contextClassLoader,
                                     CompletableFuture<?> taskQueued)
        Constructor. Specify a thread pool key if a @Bulkhead is specified on the method. A unique thread pool key will enable setting limits for this command only based on the Bulkhead properties.
        Parameters:
        commandRetrier - The command retrier associated with this command.
        commandKey - The command key.
        introspector - The method introspector.
        context - CDI invocation context.
        contextClassLoader - Context class loader or null if not available.
        taskQueued - Future completed when task has been queued.
    • Method Detail

      • run

        public Object run()
                   throws Exception
        Code to run as part of this command. Called from superclass.
        Specified by:
        run in class com.netflix.hystrix.HystrixCommand<Object>
        Returns:
        Result of command.
        Throws:
        Exception - If an error occurs.
      • execute

        public Object execute()
        Executes this command returning a result or throwing an exception.
        Specified by:
        execute in interface com.netflix.hystrix.HystrixExecutable<Object>
        Overrides:
        execute in class com.netflix.hystrix.HystrixCommand<Object>
        Returns:
        The result.
        Throws:
        RuntimeException - If something goes wrong.
      • observe

        public rx.Observable<R> observe()
        Specified by:
        observe in interface com.netflix.hystrix.HystrixObservable<R extends Object>
      • toObservable

        public rx.Observable<R> toObservable()
        Specified by:
        toObservable in interface com.netflix.hystrix.HystrixObservable<R extends Object>
      • shouldNotBeWrapped

        protected boolean shouldNotBeWrapped​(Throwable arg0)
      • handleThreadEnd

        protected void handleThreadEnd​(com.netflix.hystrix.AbstractCommand<R> arg0)
      • shouldOutputOnNextEvents

        protected boolean shouldOutputOnNextEvents()
      • getFallbackSemaphore

        protected com.netflix.hystrix.AbstractCommand.TryableSemaphore getFallbackSemaphore()
      • getExecutionSemaphore

        protected com.netflix.hystrix.AbstractCommand.TryableSemaphore getExecutionSemaphore()
      • getCommandGroup

        public com.netflix.hystrix.HystrixCommandGroupKey getCommandGroup()
        Specified by:
        getCommandGroup in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • getCommandKey

        public com.netflix.hystrix.HystrixCommandKey getCommandKey()
        Specified by:
        getCommandKey in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • getThreadPoolKey

        public com.netflix.hystrix.HystrixThreadPoolKey getThreadPoolKey()
        Specified by:
        getThreadPoolKey in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • getMetrics

        public com.netflix.hystrix.HystrixCommandMetrics getMetrics()
        Specified by:
        getMetrics in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • getProperties

        public com.netflix.hystrix.HystrixCommandProperties getProperties()
        Specified by:
        getProperties in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • getCacheKey

        protected String getCacheKey()
      • getPublicCacheKey

        public String getPublicCacheKey()
        Specified by:
        getPublicCacheKey in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • isRequestCachingEnabled

        protected boolean isRequestCachingEnabled()
      • getLogMessagePrefix

        protected String getLogMessagePrefix()
      • isCircuitBreakerOpen

        public boolean isCircuitBreakerOpen()
        Specified by:
        isCircuitBreakerOpen in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • isExecutionComplete

        public boolean isExecutionComplete()
        Specified by:
        isExecutionComplete in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • isExecutedInThread

        public boolean isExecutedInThread()
        Specified by:
        isExecutedInThread in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • isSuccessfulExecution

        public boolean isSuccessfulExecution()
        Specified by:
        isSuccessfulExecution in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • isFailedExecution

        public boolean isFailedExecution()
        Specified by:
        isFailedExecution in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • getFailedExecutionException

        public Throwable getFailedExecutionException()
        Specified by:
        getFailedExecutionException in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • getExecutionException

        public Throwable getExecutionException()
      • isResponseFromFallback

        public boolean isResponseFromFallback()
        Specified by:
        isResponseFromFallback in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • isResponseTimedOut

        public boolean isResponseTimedOut()
        Specified by:
        isResponseTimedOut in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • isResponseShortCircuited

        public boolean isResponseShortCircuited()
        Specified by:
        isResponseShortCircuited in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • isResponseFromCache

        public boolean isResponseFromCache()
        Specified by:
        isResponseFromCache in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • isResponseSemaphoreRejected

        public boolean isResponseSemaphoreRejected()
        Specified by:
        isResponseSemaphoreRejected in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • isResponseThreadPoolRejected

        public boolean isResponseThreadPoolRejected()
        Specified by:
        isResponseThreadPoolRejected in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • isResponseRejected

        public boolean isResponseRejected()
        Specified by:
        isResponseRejected in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • getExecutionEvents

        public List<com.netflix.hystrix.HystrixEventType> getExecutionEvents()
        Specified by:
        getExecutionEvents in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • getNumberEmissions

        public int getNumberEmissions()
        Specified by:
        getNumberEmissions in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • getNumberFallbackEmissions

        public int getNumberFallbackEmissions()
        Specified by:
        getNumberFallbackEmissions in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • getNumberCollapsed

        public int getNumberCollapsed()
        Specified by:
        getNumberCollapsed in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • getOriginatingCollapserKey

        public com.netflix.hystrix.HystrixCollapserKey getOriginatingCollapserKey()
        Specified by:
        getOriginatingCollapserKey in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • getExecutionTimeInMilliseconds

        public int getExecutionTimeInMilliseconds()
        Specified by:
        getExecutionTimeInMilliseconds in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • getCommandRunStartTimeInNanos

        public long getCommandRunStartTimeInNanos()
        Specified by:
        getCommandRunStartTimeInNanos in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • getEventCounts

        public com.netflix.hystrix.ExecutionResult.EventCounts getEventCounts()
        Specified by:
        getEventCounts in interface com.netflix.hystrix.HystrixInvokableInfo<R extends Object>
      • getExceptionFromThrowable

        protected Exception getExceptionFromThrowable​(Throwable arg0)