Hystrix: Latency and Fault Tolerance for Distributed Systems



com.netflix.hystrix
Class HystrixCommandProperties

java.lang.Object
  extended by com.netflix.hystrix.HystrixCommandProperties

public abstract class HystrixCommandProperties
extends java.lang.Object

Properties for instances of HystrixCommand.

Default implementation of methods uses Archaius (https://github.com/Netflix/archaius)


Nested Class Summary
static class HystrixCommandProperties.ExecutionIsolationStrategy
          Isolation strategy to use when executing a HystrixCommand.
static class HystrixCommandProperties.Setter
          Fluent interface that allows chained setting of properties that can be passed into a HystrixCommand constructor to inject instance specific property overrides.
 
Constructor Summary
protected HystrixCommandProperties(HystrixCommandKey key)
           
protected HystrixCommandProperties(HystrixCommandKey key, HystrixCommandProperties.Setter builder)
           
protected HystrixCommandProperties(HystrixCommandKey key, HystrixCommandProperties.Setter builder, java.lang.String propertyPrefix)
           
 
Method Summary
 HystrixProperty<java.lang.Boolean> circuitBreakerEnabled()
          Whether to use a HystrixCircuitBreaker or not.
 HystrixProperty<java.lang.Integer> circuitBreakerErrorThresholdPercentage()
          Error percentage threshold (as whole number such as 50) at which point the circuit breaker will trip open and reject requests.
 HystrixProperty<java.lang.Boolean> circuitBreakerForceClosed()
          If true the HystrixCircuitBreaker.allowRequest() will always return true to allow requests regardless of the error percentage from HystrixCommandMetrics.getHealthCounts().
 HystrixProperty<java.lang.Boolean> circuitBreakerForceOpen()
          If true the HystrixCircuitBreaker.allowRequest() will always return false, causing the circuit to be open (tripped) and reject all requests.
 HystrixProperty<java.lang.Integer> circuitBreakerRequestVolumeThreshold()
          Minimum number of requests in the HystrixCommandProperties.metricsRollingStatisticalWindowInMilliseconds() that must exist before the HystrixCircuitBreaker will trip.
 HystrixProperty<java.lang.Integer> circuitBreakerSleepWindowInMilliseconds()
          The time in milliseconds after a HystrixCircuitBreaker trips open that it should wait before trying requests again.
 HystrixProperty<java.lang.Integer> executionIsolationSemaphoreMaxConcurrentRequests()
          Number of concurrent requests permitted to HystrixCommand.run().
 HystrixProperty<HystrixCommandProperties.ExecutionIsolationStrategy> executionIsolationStrategy()
          What isolation strategy HystrixCommand.run() will be executed with.
 HystrixProperty<java.lang.Boolean> executionIsolationThreadInterruptOnTimeout()
          Whether the execution thread should attempt an interrupt (using Future.cancel(boolean)) when a thread times out.
 HystrixProperty<java.lang.String> executionIsolationThreadPoolKeyOverride()
          Allow a dynamic override of the HystrixThreadPoolKey that will dynamically change which HystrixThreadPool a HystrixCommand executes on.
 HystrixProperty<java.lang.Integer> executionIsolationThreadTimeoutInMilliseconds()
          Time in milliseconds at which point the calling thread will timeout (using Future.get()) and walk away from the executing thread.
 HystrixProperty<java.lang.Boolean> fallbackEnabled()
          Whether HystrixCommand.getFallback() should be attempted when failure occurs.
 HystrixProperty<java.lang.Integer> fallbackIsolationSemaphoreMaxConcurrentRequests()
          Number of concurrent requests permitted to HystrixCommand.getFallback().
 HystrixProperty<java.lang.Integer> metricsHealthSnapshotIntervalInMilliseconds()
          Time in milliseconds to wait between allowing health snapshots to be taken that calculate success and error percentages and affect HystrixCircuitBreaker.isOpen() status.
 HystrixProperty<java.lang.Integer> metricsRollingPercentileBucketSize()
          Maximum number of values stored in each bucket of the rolling percentile.
 HystrixProperty<java.lang.Boolean> metricsRollingPercentileEnabled()
          Whether percentile metrics should be captured using HystrixRollingPercentile inside HystrixCommandMetrics.
 HystrixProperty<java.lang.Integer> metricsRollingPercentileWindow()
          Deprecated. Use HystrixCommandProperties.metricsRollingPercentileWindowInMilliseconds()
 HystrixProperty<java.lang.Integer> metricsRollingPercentileWindowBuckets()
          Number of buckets the rolling percentile window is broken into.
 HystrixProperty<java.lang.Integer> metricsRollingPercentileWindowInMilliseconds()
          Duration of percentile rolling window in milliseconds.
 HystrixProperty<java.lang.Integer> metricsRollingStatisticalWindowBuckets()
          Number of buckets the rolling statistical window is broken into.
 HystrixProperty<java.lang.Integer> metricsRollingStatisticalWindowInMilliseconds()
          Duration of statistical rolling window in milliseconds.
 HystrixProperty<java.lang.Boolean> requestCacheEnabled()
          Whether HystrixCommand.getCacheKey() should be used with HystrixRequestCache to provide de-duplication functionality via request-scoped caching.
 HystrixProperty<java.lang.Boolean> requestLogEnabled()
          Whether HystrixCommand execution and events should be logged to HystrixRequestLog.
static HystrixCommandProperties.Setter Setter()
          Factory method to retrieve the default Setter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HystrixCommandProperties

protected HystrixCommandProperties(HystrixCommandKey key)

HystrixCommandProperties

protected HystrixCommandProperties(HystrixCommandKey key,
                                   HystrixCommandProperties.Setter builder)

HystrixCommandProperties

protected HystrixCommandProperties(HystrixCommandKey key,
                                   HystrixCommandProperties.Setter builder,
                                   java.lang.String propertyPrefix)
Method Detail

circuitBreakerEnabled

public HystrixProperty<java.lang.Boolean> circuitBreakerEnabled()
Whether to use a HystrixCircuitBreaker or not. If false no circuit-breaker logic will be used and all requests permitted.

This is similar in effect to HystrixCommandProperties.circuitBreakerForceClosed() except that continues tracking metrics and knowing whether it should be open/closed, this property results in not even instantiating a circuit-breaker.

Returns:
HystrixProperty<Boolean>

circuitBreakerErrorThresholdPercentage

public HystrixProperty<java.lang.Integer> circuitBreakerErrorThresholdPercentage()
Error percentage threshold (as whole number such as 50) at which point the circuit breaker will trip open and reject requests.

It will stay tripped for the duration defined in HystrixCommandProperties.circuitBreakerSleepWindowInMilliseconds();

The error percentage this is compared against comes from HystrixCommandMetrics.getHealthCounts().

Returns:
HystrixProperty<Integer>

circuitBreakerForceClosed

public HystrixProperty<java.lang.Boolean> circuitBreakerForceClosed()
If true the HystrixCircuitBreaker.allowRequest() will always return true to allow requests regardless of the error percentage from HystrixCommandMetrics.getHealthCounts().

The HystrixCommandProperties.circuitBreakerForceOpen() property takes precedence so if it set to true this property does nothing.

Returns:
HystrixProperty<Boolean>

circuitBreakerForceOpen

public HystrixProperty<java.lang.Boolean> circuitBreakerForceOpen()
If true the HystrixCircuitBreaker.allowRequest() will always return false, causing the circuit to be open (tripped) and reject all requests.

This property takes precedence over HystrixCommandProperties.circuitBreakerForceClosed();

Returns:
HystrixProperty<Boolean>

circuitBreakerRequestVolumeThreshold

public HystrixProperty<java.lang.Integer> circuitBreakerRequestVolumeThreshold()
Minimum number of requests in the HystrixCommandProperties.metricsRollingStatisticalWindowInMilliseconds() that must exist before the HystrixCircuitBreaker will trip.

If below this number the circuit will not trip regardless of error percentage.

Returns:
HystrixProperty<Integer>

circuitBreakerSleepWindowInMilliseconds

public HystrixProperty<java.lang.Integer> circuitBreakerSleepWindowInMilliseconds()
The time in milliseconds after a HystrixCircuitBreaker trips open that it should wait before trying requests again.

Returns:
HystrixProperty<Integer>

executionIsolationSemaphoreMaxConcurrentRequests

public HystrixProperty<java.lang.Integer> executionIsolationSemaphoreMaxConcurrentRequests()
Number of concurrent requests permitted to HystrixCommand.run(). Requests beyond the concurrent limit will be rejected.

Applicable only when HystrixCommandProperties.executionIsolationStrategy() == SEMAPHORE.

Returns:
HystrixProperty<Integer>

executionIsolationStrategy

public HystrixProperty<HystrixCommandProperties.ExecutionIsolationStrategy> executionIsolationStrategy()
What isolation strategy HystrixCommand.run() will be executed with.

If HystrixCommandProperties.ExecutionIsolationStrategy.THREAD then it will be executed on a separate thread and concurrent requests limited by the number of threads in the thread-pool.

If HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE then it will be executed on the calling thread and concurrent requests limited by the semaphore count.

Returns:
HystrixProperty<Boolean>

executionIsolationThreadInterruptOnTimeout

public HystrixProperty<java.lang.Boolean> executionIsolationThreadInterruptOnTimeout()
Whether the execution thread should attempt an interrupt (using Future.cancel(boolean)) when a thread times out.

Applicable only when HystrixCommandProperties.executionIsolationStrategy() == THREAD.

Returns:
HystrixProperty<Boolean>

executionIsolationThreadPoolKeyOverride

public HystrixProperty<java.lang.String> executionIsolationThreadPoolKeyOverride()
Allow a dynamic override of the HystrixThreadPoolKey that will dynamically change which HystrixThreadPool a HystrixCommand executes on.

Typically this should return NULL which will cause it to use the HystrixThreadPoolKey injected into a HystrixCommand or derived from the HystrixCommandGroupKey.

When set the injected or derived values will be ignored and a new HystrixThreadPool created (if necessary) and the HystrixCommand will begin using the newly defined pool.

Returns:
HystrixProperty<String>

executionIsolationThreadTimeoutInMilliseconds

public HystrixProperty<java.lang.Integer> executionIsolationThreadTimeoutInMilliseconds()
Time in milliseconds at which point the calling thread will timeout (using Future.get()) and walk away from the executing thread.

If HystrixCommandProperties.executionIsolationThreadInterruptOnTimeout == true the executing thread will be interrupted.

Applicable only when HystrixCommandProperties.executionIsolationStrategy() == THREAD.

Returns:
HystrixProperty<Integer>

fallbackIsolationSemaphoreMaxConcurrentRequests

public HystrixProperty<java.lang.Integer> fallbackIsolationSemaphoreMaxConcurrentRequests()
Number of concurrent requests permitted to HystrixCommand.getFallback(). Requests beyond the concurrent limit will fail-fast and not attempt retrieving a fallback.

Returns:
HystrixProperty<Integer>

fallbackEnabled

public HystrixProperty<java.lang.Boolean> fallbackEnabled()
Whether HystrixCommand.getFallback() should be attempted when failure occurs.

Returns:
HystrixProperty<Boolean>
Since:
1.2

metricsHealthSnapshotIntervalInMilliseconds

public HystrixProperty<java.lang.Integer> metricsHealthSnapshotIntervalInMilliseconds()
Time in milliseconds to wait between allowing health snapshots to be taken that calculate success and error percentages and affect HystrixCircuitBreaker.isOpen() status.

On high-volume circuits the continual calculation of error percentage can become CPU intensive thus this controls how often it is calculated.

Returns:
HystrixProperty<Integer>

metricsRollingPercentileBucketSize

public HystrixProperty<java.lang.Integer> metricsRollingPercentileBucketSize()
Maximum number of values stored in each bucket of the rolling percentile. This is passed into HystrixRollingPercentile inside HystrixCommandMetrics.

Returns:
HystrixProperty<Integer>

metricsRollingPercentileEnabled

public HystrixProperty<java.lang.Boolean> metricsRollingPercentileEnabled()
Whether percentile metrics should be captured using HystrixRollingPercentile inside HystrixCommandMetrics.

Returns:
HystrixProperty<Boolean>

metricsRollingPercentileWindow

public HystrixProperty<java.lang.Integer> metricsRollingPercentileWindow()
Deprecated. Use HystrixCommandProperties.metricsRollingPercentileWindowInMilliseconds()

Duration of percentile rolling window in milliseconds. This is passed into HystrixRollingPercentile inside HystrixCommandMetrics.

Returns:
HystrixProperty<Integer>

metricsRollingPercentileWindowInMilliseconds

public HystrixProperty<java.lang.Integer> metricsRollingPercentileWindowInMilliseconds()
Duration of percentile rolling window in milliseconds. This is passed into HystrixRollingPercentile inside HystrixCommandMetrics.

Returns:
HystrixProperty<Integer>

metricsRollingPercentileWindowBuckets

public HystrixProperty<java.lang.Integer> metricsRollingPercentileWindowBuckets()
Number of buckets the rolling percentile window is broken into. This is passed into HystrixRollingPercentile inside HystrixCommandMetrics.

Returns:
HystrixProperty<Integer>

metricsRollingStatisticalWindowInMilliseconds

public HystrixProperty<java.lang.Integer> metricsRollingStatisticalWindowInMilliseconds()
Duration of statistical rolling window in milliseconds. This is passed into HystrixRollingNumber inside HystrixCommandMetrics.

Returns:
HystrixProperty<Integer>

metricsRollingStatisticalWindowBuckets

public HystrixProperty<java.lang.Integer> metricsRollingStatisticalWindowBuckets()
Number of buckets the rolling statistical window is broken into. This is passed into HystrixRollingNumber inside HystrixCommandMetrics.

Returns:
HystrixProperty<Integer>

requestCacheEnabled

public HystrixProperty<java.lang.Boolean> requestCacheEnabled()
Whether HystrixCommand.getCacheKey() should be used with HystrixRequestCache to provide de-duplication functionality via request-scoped caching.

Returns:
HystrixProperty<Boolean>

requestLogEnabled

public HystrixProperty<java.lang.Boolean> requestLogEnabled()
Whether HystrixCommand execution and events should be logged to HystrixRequestLog.

Returns:
HystrixProperty<Boolean>

Setter

public static HystrixCommandProperties.Setter Setter()
Factory method to retrieve the default Setter.