Hystrix: Latency and Fault Tolerance for Distributed Systems



com.netflix.hystrix
Class HystrixThreadPoolMetrics

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

public class HystrixThreadPoolMetrics
extends java.lang.Object

Used by HystrixThreadPool to record metrics.


Method Summary
 long getCumulativeCountThreadsExecuted()
          Cumulative count of number of threads executed since the start of the application.
 java.lang.Number getCurrentActiveCount()
          Value from ThreadPoolExecutor.getActiveCount()
 java.lang.Number getCurrentCompletedTaskCount()
          Value from ThreadPoolExecutor.getCompletedTaskCount()
 java.lang.Number getCurrentCorePoolSize()
          Value from ThreadPoolExecutor.getCorePoolSize()
 java.lang.Number getCurrentLargestPoolSize()
          Value from ThreadPoolExecutor.getLargestPoolSize()
 java.lang.Number getCurrentMaximumPoolSize()
          Value from ThreadPoolExecutor.getMaximumPoolSize()
 java.lang.Number getCurrentPoolSize()
          Value from ThreadPoolExecutor.getPoolSize()
 java.lang.Number getCurrentQueueSize()
          Current size of BlockingQueue used by the thread-pool
 java.lang.Number getCurrentTaskCount()
          Value from ThreadPoolExecutor.getTaskCount()
static HystrixThreadPoolMetrics getInstance(HystrixThreadPoolKey key)
          Get the HystrixThreadPoolMetrics instance for a given HystrixThreadPoolKey or null if one does not exist.
static HystrixThreadPoolMetrics getInstance(HystrixThreadPoolKey key, java.util.concurrent.ThreadPoolExecutor threadPool, HystrixThreadPoolProperties properties)
          Get or create the HystrixThreadPoolMetrics instance for a given HystrixThreadPoolKey.
static java.util.Collection<HystrixThreadPoolMetrics> getInstances()
          All registered instances of HystrixThreadPoolMetrics
 HystrixThreadPoolProperties getProperties()
          HystrixThreadPoolProperties of the HystrixThreadPool these metrics represent.
 long getRollingCountThreadsExecuted()
          Rolling count of number of threads executed during rolling statistical window.
 long getRollingMaxActiveThreads()
          Rolling max number of active threads during rolling statistical window.
 HystrixThreadPoolKey getThreadPoolKey()
          HystrixThreadPoolKey these metrics represent.
 void markThreadCompletion()
          Invoked each time a thread completes.
 void markThreadExecution()
          Invoked each time a thread is executed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static HystrixThreadPoolMetrics getInstance(HystrixThreadPoolKey key,
                                                   java.util.concurrent.ThreadPoolExecutor threadPool,
                                                   HystrixThreadPoolProperties properties)
Get or create the HystrixThreadPoolMetrics instance for a given HystrixThreadPoolKey.

This is thread-safe and ensures only 1 HystrixThreadPoolMetrics per HystrixThreadPoolKey.

Parameters:
key - HystrixThreadPoolKey of HystrixThreadPool instance requesting the HystrixThreadPoolMetrics
threadPool - Pass-thru of ThreadPoolExecutor to HystrixThreadPoolMetrics instance on first time when constructed
properties - Pass-thru to HystrixThreadPoolMetrics instance on first time when constructed
Returns:
HystrixThreadPoolMetrics

getInstance

public static HystrixThreadPoolMetrics getInstance(HystrixThreadPoolKey key)
Get the HystrixThreadPoolMetrics instance for a given HystrixThreadPoolKey or null if one does not exist.

Parameters:
key - HystrixThreadPoolKey of HystrixThreadPool instance requesting the HystrixThreadPoolMetrics
Returns:
HystrixThreadPoolMetrics

getInstances

public static java.util.Collection<HystrixThreadPoolMetrics> getInstances()
All registered instances of HystrixThreadPoolMetrics

Returns:
Collection<HystrixThreadPoolMetrics>

getThreadPoolKey

public HystrixThreadPoolKey getThreadPoolKey()
HystrixThreadPoolKey these metrics represent.

Returns:
HystrixThreadPoolKey

getProperties

public HystrixThreadPoolProperties getProperties()
HystrixThreadPoolProperties of the HystrixThreadPool these metrics represent.

Returns:
HystrixThreadPoolProperties

getCurrentActiveCount

public java.lang.Number getCurrentActiveCount()
Value from ThreadPoolExecutor.getActiveCount()

Returns:
Number

getCurrentCompletedTaskCount

public java.lang.Number getCurrentCompletedTaskCount()
Value from ThreadPoolExecutor.getCompletedTaskCount()

Returns:
Number

getCurrentCorePoolSize

public java.lang.Number getCurrentCorePoolSize()
Value from ThreadPoolExecutor.getCorePoolSize()

Returns:
Number

getCurrentLargestPoolSize

public java.lang.Number getCurrentLargestPoolSize()
Value from ThreadPoolExecutor.getLargestPoolSize()

Returns:
Number

getCurrentMaximumPoolSize

public java.lang.Number getCurrentMaximumPoolSize()
Value from ThreadPoolExecutor.getMaximumPoolSize()

Returns:
Number

getCurrentPoolSize

public java.lang.Number getCurrentPoolSize()
Value from ThreadPoolExecutor.getPoolSize()

Returns:
Number

getCurrentTaskCount

public java.lang.Number getCurrentTaskCount()
Value from ThreadPoolExecutor.getTaskCount()

Returns:
Number

getCurrentQueueSize

public java.lang.Number getCurrentQueueSize()
Current size of BlockingQueue used by the thread-pool

Returns:
Number

markThreadExecution

public void markThreadExecution()
Invoked each time a thread is executed.


getRollingCountThreadsExecuted

public long getRollingCountThreadsExecuted()
Rolling count of number of threads executed during rolling statistical window.

The rolling window is defined by HystrixThreadPoolProperties.metricsRollingStatisticalWindowInMilliseconds().

Returns:
rolling count of threads executed

getCumulativeCountThreadsExecuted

public long getCumulativeCountThreadsExecuted()
Cumulative count of number of threads executed since the start of the application.

Returns:
cumulative count of threads executed

markThreadCompletion

public void markThreadCompletion()
Invoked each time a thread completes.


getRollingMaxActiveThreads

public long getRollingMaxActiveThreads()
Rolling max number of active threads during rolling statistical window.

The rolling window is defined by HystrixThreadPoolProperties.metricsRollingStatisticalWindowInMilliseconds().

Returns:
rolling max active threads