Class CircuitBreakerCommand

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

    public class CircuitBreakerCommand
    extends com.netflix.hystrix.HystrixCommand<Stock>
    Hystrix command that fetches a stock quote with circuit breaker and timeout support.
    • 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
      • commandKey

        protected final com.netflix.hystrix.HystrixCommandKey commandKey
      • 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 java.util.concurrent.ConcurrentHashMap<java.lang.String,​com.netflix.hystrix.AbstractCommand.TryableSemaphore> fallbackSemaphorePerCircuit
      • executionSemaphoreOverride

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

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

        protected final java.util.concurrent.atomic.AtomicReference<java.lang.ref.Reference<com.netflix.hystrix.util.HystrixTimer.TimerListener>> timeoutTimer
      • started

        protected java.util.concurrent.atomic.AtomicBoolean started
      • executionResult

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

        protected final java.util.concurrent.atomic.AtomicReference<com.netflix.hystrix.AbstractCommand.TimedOutStatus> isCommandTimedOut
      • isExecutionComplete

        protected final java.util.concurrent.atomic.AtomicBoolean isExecutionComplete
      • endCurrentThreadExecutingCommand

        protected final java.util.concurrent.atomic.AtomicReference<rx.functions.Action0> endCurrentThreadExecutingCommand
      • requestCache

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

        protected final com.netflix.hystrix.HystrixRequestLog currentRequestLog
    • Method Detail

      • run

        protected Stock run()
        Specified by:
        run in class com.netflix.hystrix.HystrixCommand<Stock>
      • getFallback

        protected Stock getFallback()
        Overrides:
        getFallback in class com.netflix.hystrix.HystrixCommand<Stock>
      • observe

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

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

        protected void handleThreadEnd()
      • 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 java.lang.Object>
      • getCommandKey

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

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

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

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

        protected void recordExecutedCommand()
      • decomposeException

        protected java.lang.RuntimeException decomposeException​(java.lang.Exception arg0)
      • getCacheKey

        protected java.lang.String getCacheKey()
      • getPublicCacheKey

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

        protected boolean isRequestCachingEnabled()
      • getLogMessagePrefix

        protected java.lang.String getLogMessagePrefix()
      • isCircuitBreakerOpen

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

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

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

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

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

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

        public java.lang.Throwable getExecutionException()
      • isResponseFromFallback

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        protected java.lang.Exception getExceptionFromThrowable​(java.lang.Throwable arg0)