Class CPUCircuitBreaker
- java.lang.Object
-
- org.apache.solr.util.circuitbreaker.CircuitBreaker
-
- org.apache.solr.util.circuitbreaker.CPUCircuitBreaker
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,NamedListInitializedPlugin
public class CPUCircuitBreaker extends CircuitBreaker
Tracks current CPU usage and triggers if the specified threshold is breached.This circuit breaker gets the recent average CPU usage and uses that data to take a decision. We depend on OperatingSystemMXBean which does not allow a configurable interval of collection of data.
-
-
Constructor Summary
Constructors Constructor Description CPUCircuitBreaker(SolrCore core)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected double
calculateLiveCPUUsage()
Calculate the CPU usage for the system in percentage.double
getCpuUsageThreshold()
String
getErrorMessage()
Get error message when the circuit breaker triggersvoid
init(org.apache.solr.common.util.NamedList<?> args)
init
will be called just once, immediately after creation.boolean
isTripped()
Check if circuit breaker is tripped.void
setThreshold(double thresholdValueInPercentage)
-
Methods inherited from class org.apache.solr.util.circuitbreaker.CircuitBreaker
close, getErrorCode, getRequestTypes, setRequestTypes
-
-
-
-
Constructor Detail
-
CPUCircuitBreaker
public CPUCircuitBreaker(SolrCore core)
-
-
Method Detail
-
init
public void init(org.apache.solr.common.util.NamedList<?> args)
Description copied from interface:NamedListInitializedPlugin
init
will be called just once, immediately after creation.Source of the initialization arguments will typically be solrconfig.xml, but will ultimately depends on the plugin itself
- Specified by:
init
in interfaceNamedListInitializedPlugin
- Overrides:
init
in classCircuitBreaker
- Parameters:
args
- non-null list of initialization parameters (may be empty)
-
isTripped
public boolean isTripped()
Description copied from class:CircuitBreaker
Check if circuit breaker is tripped.- Specified by:
isTripped
in classCircuitBreaker
-
getErrorMessage
public String getErrorMessage()
Description copied from class:CircuitBreaker
Get error message when the circuit breaker triggers- Specified by:
getErrorMessage
in classCircuitBreaker
-
setThreshold
public void setThreshold(double thresholdValueInPercentage)
-
getCpuUsageThreshold
public double getCpuUsageThreshold()
-
calculateLiveCPUUsage
protected double calculateLiveCPUUsage()
Calculate the CPU usage for the system in percentage.- Returns:
- Percent CPU usage of -1 if value could not be obtained.
-
-