com.netflix.hystrix.strategy.properties
Class HystrixPropertiesStrategy

java.lang.Object
  extended by com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy

public abstract class HystrixPropertiesStrategy
extends java.lang.Object

Abstract class with default implementations of factory methods for properties used by various components of Hystrix.

Custom implementations of this interface can be used to override default behavior via 2 mechanisms:

1) Injection

Implementations can be injected into HystrixCommand and HystrixCollapser implementation constructors.

2) Plugin

Using HystrixPlugins.registerPropertiesStrategy(com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy) an implementation can be registered globally to take precedence and override all other implementations.

The order of precedence is:

  1. plugin registered globally using HystrixPlugins.registerPropertiesStrategy(com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy)
  2. injected via HystrixCommand and HystrixCollapser constructors
  3. default implementation HystrixPropertiesStrategyDefault

The injection approach is effective for HystrixCommand and HystrixCollapser implementations where you wish to have a different default mechanism for setting properties without overriding all implementations. It is also useful when distributing a library where static override should not be used.

The globally registered plugin is useful when using commands from 3rd party libraries and you want to override how properties are defined for all implementations in your entire system.


Constructor Summary
HystrixPropertiesStrategy()
           
 
Method Summary
 HystrixCollapserProperties getCollapserProperties(HystrixCollapserKey collapserKey, HystrixCollapserProperties.Setter builder)
          Construct an implementation of HystrixCollapserProperties for HystrixCollapser instances with HystrixCollapserKey.
 java.lang.String getCollapserPropertiesCacheKey(HystrixCollapserKey collapserKey, HystrixCollapserProperties.Setter builder)
          Cache key used for caching the retrieval of HystrixCollapserProperties implementations.
 HystrixCommandProperties getCommandProperties(HystrixCommandKey commandKey, HystrixCommandProperties.Setter builder)
          Construct an implementation of HystrixCommandProperties for HystrixCommand instances with HystrixCommandKey.
 java.lang.String getCommandPropertiesCacheKey(HystrixCommandKey commandKey, HystrixCommandProperties.Setter builder)
          Cache key used for caching the retrieval of HystrixCommandProperties implementations.
 HystrixThreadPoolProperties getThreadPoolProperties(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolProperties.Setter builder)
          Construct an implementation of HystrixThreadPoolProperties for HystrixThreadPool instances with HystrixThreadPoolKey.
 java.lang.String getThreadPoolPropertiesCacheKey(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolProperties.Setter builder)
          Cache key used for caching the retrieval of HystrixThreadPoolProperties implementations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HystrixPropertiesStrategy

public HystrixPropertiesStrategy()
Method Detail

getCommandProperties

public HystrixCommandProperties getCommandProperties(HystrixCommandKey commandKey,
                                                     HystrixCommandProperties.Setter builder)
Construct an implementation of HystrixCommandProperties for HystrixCommand instances with HystrixCommandKey.

Default Implementation

Constructs instance of HystrixPropertiesCommandDefault.

Parameters:
commandKey - HystrixCommandKey representing the name or type of HystrixCommand
builder - HystrixCommandProperties.Setter with default overrides as injected from the HystrixCommand implementation.

The builder will return NULL for each value if no override was provided.

Returns:
Implementation of HystrixCommandProperties

getCommandPropertiesCacheKey

public java.lang.String getCommandPropertiesCacheKey(HystrixCommandKey commandKey,
                                                     HystrixCommandProperties.Setter builder)
Cache key used for caching the retrieval of HystrixCommandProperties implementations.

Typically this would return HystrixCommandKey.name() but can be done differently if required.

For example, null can be returned which would cause it to not cache and invoke HystrixPropertiesStrategy.getCommandProperties(com.netflix.hystrix.HystrixCommandKey, com.netflix.hystrix.HystrixCommandProperties.Setter) for each HystrixCommand instantiation (not recommended).

Default Implementation

Returns HystrixCommandKey.name()

Parameters:
commandKey -
builder -
Returns:
String value to be used as the cache key of a HystrixCommandProperties implementation.

getThreadPoolProperties

public HystrixThreadPoolProperties getThreadPoolProperties(HystrixThreadPoolKey threadPoolKey,
                                                           HystrixThreadPoolProperties.Setter builder)
Construct an implementation of HystrixThreadPoolProperties for HystrixThreadPool instances with HystrixThreadPoolKey.

Default Implementation

Constructs instance of HystrixPropertiesThreadPoolDefault.

Parameters:
threadPoolKey - HystrixThreadPoolKey representing the name or type of HystrixThreadPool
builder - HystrixThreadPoolProperties.Setter with default overrides as injected via HystrixCommand to the HystrixThreadPool implementation.

The builder will return NULL for each value if no override was provided.

Returns:
Implementation of HystrixThreadPoolProperties

getThreadPoolPropertiesCacheKey

public java.lang.String getThreadPoolPropertiesCacheKey(HystrixThreadPoolKey threadPoolKey,
                                                        HystrixThreadPoolProperties.Setter builder)
Cache key used for caching the retrieval of HystrixThreadPoolProperties implementations.

Typically this would return HystrixThreadPoolKey.name() but can be done differently if required.

For example, null can be returned which would cause it to not cache and invoke HystrixPropertiesStrategy.getThreadPoolProperties(com.netflix.hystrix.HystrixThreadPoolKey, com.netflix.hystrix.HystrixThreadPoolProperties.Setter) for each HystrixThreadPool instantiation (not recommended).

Default Implementation

Returns HystrixThreadPoolKey.name()

Parameters:
threadPoolKey -
builder -
Returns:
String value to be used as the cache key of a HystrixThreadPoolProperties implementation.

getCollapserProperties

public HystrixCollapserProperties getCollapserProperties(HystrixCollapserKey collapserKey,
                                                         HystrixCollapserProperties.Setter builder)
Construct an implementation of HystrixCollapserProperties for HystrixCollapser instances with HystrixCollapserKey.

Default Implementation

Constructs instance of HystrixPropertiesCollapserDefault.

Parameters:
collapserKey - HystrixCollapserKey representing the name or type of HystrixCollapser
builder - HystrixCollapserProperties.Setter with default overrides as injected to the HystrixCollapser implementation.

The builder will return NULL for each value if no override was provided.

Returns:
Implementation of HystrixCollapserProperties

getCollapserPropertiesCacheKey

public java.lang.String getCollapserPropertiesCacheKey(HystrixCollapserKey collapserKey,
                                                       HystrixCollapserProperties.Setter builder)
Cache key used for caching the retrieval of HystrixCollapserProperties implementations.

Typically this would return HystrixCollapserKey.name() but can be done differently if required.

For example, null can be returned which would cause it to not cache and invoke HystrixPropertiesStrategy.getCollapserProperties(com.netflix.hystrix.HystrixCollapserKey, com.netflix.hystrix.HystrixCollapserProperties.Setter) for each HystrixCollapser instantiation (not recommended).

Default Implementation

Returns HystrixCollapserKey.name()

Parameters:
collapserKey -
builder -
Returns:
String value to be used as the cache key of a HystrixCollapserProperties implementation.