Hystrix: Latency and Fault Tolerance for Distributed Systems



com.netflix.hystrix.strategy
Class HystrixPlugins

java.lang.Object
  extended by com.netflix.hystrix.strategy.HystrixPlugins

public class HystrixPlugins
extends java.lang.Object

Registry for plugin implementations that allows global override and handles the retrieval of correct implementation based on order of precedence:

  1. plugin registered globally via register methods in this class
  2. plugin registered and retrieved using System.getProperty(String) (see get methods for property names)
  3. default implementation
See the Hystrix GitHub Wiki for more information: https://github.com/Netflix/Hystrix/wiki/Plugins.


Method Summary
 HystrixCommandExecutionHook getCommandExecutionHook()
          Retrieve instance of HystrixCommandExecutionHook to use based on order of precedence as defined in HystrixPlugins class header.
 HystrixConcurrencyStrategy getConcurrencyStrategy()
          Retrieve instance of HystrixConcurrencyStrategy to use based on order of precedence as defined in HystrixPlugins class header.
 HystrixEventNotifier getEventNotifier()
          Retrieve instance of HystrixEventNotifier to use based on order of precedence as defined in HystrixPlugins class header.
static HystrixPlugins getInstance()
           
 HystrixMetricsPublisher getMetricsPublisher()
          Retrieve instance of HystrixMetricsPublisher to use based on order of precedence as defined in HystrixPlugins class header.
 HystrixPropertiesStrategy getPropertiesStrategy()
          Retrieve instance of HystrixPropertiesStrategy to use based on order of precedence as defined in HystrixPlugins class header.
 void registerCommandExecutionHook(HystrixCommandExecutionHook impl)
          Register a HystrixCommandExecutionHook implementation as a global override of any injected or default implementations.
 void registerConcurrencyStrategy(HystrixConcurrencyStrategy impl)
          Register a HystrixConcurrencyStrategy implementation as a global override of any injected or default implementations.
 void registerEventNotifier(HystrixEventNotifier impl)
          Register a HystrixEventNotifier implementation as a global override of any injected or default implementations.
 void registerMetricsPublisher(HystrixMetricsPublisher impl)
          Register a HystrixMetricsPublisher implementation as a global override of any injected or default implementations.
 void registerPropertiesStrategy(HystrixPropertiesStrategy impl)
          Register a HystrixPropertiesStrategy implementation as a global override of any injected or default implementations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static HystrixPlugins getInstance()

getEventNotifier

public HystrixEventNotifier getEventNotifier()
Retrieve instance of HystrixEventNotifier to use based on order of precedence as defined in HystrixPlugins class header.

Override default by using HystrixPlugins.registerEventNotifier(HystrixEventNotifier) or setting property: hystrix.plugin.HystrixEventNotifier.implementation with the full classname to load.

Returns:
HystrixEventNotifier implementation to use

registerEventNotifier

public void registerEventNotifier(HystrixEventNotifier impl)
Register a HystrixEventNotifier implementation as a global override of any injected or default implementations.

Parameters:
impl - HystrixEventNotifier implementation
Throws:
java.lang.IllegalStateException - if called more than once or after the default was initialized (if usage occurs before trying to register)

getConcurrencyStrategy

public HystrixConcurrencyStrategy getConcurrencyStrategy()
Retrieve instance of HystrixConcurrencyStrategy to use based on order of precedence as defined in HystrixPlugins class header.

Override default by using HystrixPlugins.registerConcurrencyStrategy(HystrixConcurrencyStrategy) or setting property: hystrix.plugin.HystrixConcurrencyStrategy.implementation with the full classname to load.

Returns:
HystrixConcurrencyStrategy implementation to use

registerConcurrencyStrategy

public void registerConcurrencyStrategy(HystrixConcurrencyStrategy impl)
Register a HystrixConcurrencyStrategy implementation as a global override of any injected or default implementations.

Parameters:
impl - HystrixConcurrencyStrategy implementation
Throws:
java.lang.IllegalStateException - if called more than once or after the default was initialized (if usage occurs before trying to register)

getMetricsPublisher

public HystrixMetricsPublisher getMetricsPublisher()
Retrieve instance of HystrixMetricsPublisher to use based on order of precedence as defined in HystrixPlugins class header.

Override default by using HystrixPlugins.registerMetricsPublisher(HystrixMetricsPublisher) or setting property: hystrix.plugin.HystrixMetricsPublisher.implementation with the full classname to load.

Returns:
HystrixMetricsPublisher implementation to use

registerMetricsPublisher

public void registerMetricsPublisher(HystrixMetricsPublisher impl)
Register a HystrixMetricsPublisher implementation as a global override of any injected or default implementations.

Parameters:
impl - HystrixMetricsPublisher implementation
Throws:
java.lang.IllegalStateException - if called more than once or after the default was initialized (if usage occurs before trying to register)

getPropertiesStrategy

public HystrixPropertiesStrategy getPropertiesStrategy()
Retrieve instance of HystrixPropertiesStrategy to use based on order of precedence as defined in HystrixPlugins class header.

Override default by using HystrixPlugins.registerPropertiesStrategy(HystrixPropertiesStrategy) or setting property: hystrix.plugin.HystrixPropertiesStrategy.implementation with the full classname to load.

Returns:
HystrixPropertiesStrategy implementation to use

registerPropertiesStrategy

public void registerPropertiesStrategy(HystrixPropertiesStrategy impl)
Register a HystrixPropertiesStrategy implementation as a global override of any injected or default implementations.

Parameters:
impl - HystrixPropertiesStrategy implementation
Throws:
java.lang.IllegalStateException - if called more than once or after the default was initialized (if usage occurs before trying to register)

getCommandExecutionHook

public HystrixCommandExecutionHook getCommandExecutionHook()
Retrieve instance of HystrixCommandExecutionHook to use based on order of precedence as defined in HystrixPlugins class header.

Override default by using HystrixPlugins.registerCommandExecutionHook(HystrixCommandExecutionHook) or setting property: hystrix.plugin.HystrixCommandExecutionHook.implementation with the full classname to load.

Returns:
HystrixCommandExecutionHook implementation to use
Since:
1.2

registerCommandExecutionHook

public void registerCommandExecutionHook(HystrixCommandExecutionHook impl)
Register a HystrixCommandExecutionHook implementation as a global override of any injected or default implementations.

Parameters:
impl - HystrixCommandExecutionHook implementation
Throws:
java.lang.IllegalStateException - if called more than once or after the default was initialized (if usage occurs before trying to register)
Since:
1.2