Class CircuitBreakerManager
- java.lang.Object
-
- org.apache.solr.util.circuitbreaker.CircuitBreakerManager
-
- All Implemented Interfaces:
PluginInfoInitialized
public class CircuitBreakerManager extends Object implements PluginInfoInitialized
Manages all registered circuit breaker instances. Responsible for a holistic view of whether a circuit breaker has tripped or not.There are two typical ways of using this class's instance: 1. Check if any circuit breaker has triggered -- and know which circuit breaker has triggered. 2. Get an instance of a specific circuit breaker and perform checks.
It is a good practice to register new circuit breakers here if you want them checked for every request.
NOTE: The current way of registering new default circuit breakers is minimal and not a long term solution. There will be a follow up with a SIP for a schema API design.
-
-
Constructor Summary
Constructors Constructor Description CircuitBreakerManager(boolean enableCircuitBreakerManager)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CircuitBreakerManager
build(PluginInfo pluginInfo)
Register default circuit breakers and return a constructed CircuitBreakerManager instance which serves the given circuit breakers.static CircuitBreaker.CircuitBreakerConfig
buildCBConfig(PluginInfo pluginInfo)
boolean
checkAnyTripped()
Returns true if *any* circuit breaker has triggered, false if none have triggered.List<CircuitBreaker>
checkTripped()
Check and return circuit breakers that have triggeredvoid
deregisterAll()
List<CircuitBreaker>
getRegisteredCircuitBreakers()
void
init(PluginInfo pluginInfo)
boolean
isEnabled()
void
register(CircuitBreaker circuitBreaker)
static String
toErrorMessage(List<CircuitBreaker> circuitBreakerList)
Construct the final error message to be printed when circuit breakers trip.
-
-
-
Method Detail
-
init
public void init(PluginInfo pluginInfo)
- Specified by:
init
in interfacePluginInfoInitialized
-
register
public void register(CircuitBreaker circuitBreaker)
-
deregisterAll
public void deregisterAll()
-
checkTripped
public List<CircuitBreaker> checkTripped()
Check and return circuit breakers that have triggered- Returns:
- CircuitBreakers which have triggered, null otherwise.
-
checkAnyTripped
public boolean checkAnyTripped()
Returns true if *any* circuit breaker has triggered, false if none have triggered.NOTE: This method short circuits the checking of circuit breakers -- the method will return as soon as it finds a circuit breaker that is enabled and has triggered.
-
toErrorMessage
public static String toErrorMessage(List<CircuitBreaker> circuitBreakerList)
Construct the final error message to be printed when circuit breakers trip.- Parameters:
circuitBreakerList
- Input list for circuit breakers.- Returns:
- Constructed error message.
-
build
public static CircuitBreakerManager build(PluginInfo pluginInfo)
Register default circuit breakers and return a constructed CircuitBreakerManager instance which serves the given circuit breakers.Any default circuit breakers should be registered here.
-
buildCBConfig
public static CircuitBreaker.CircuitBreakerConfig buildCBConfig(PluginInfo pluginInfo)
-
isEnabled
public boolean isEnabled()
-
getRegisteredCircuitBreakers
public List<CircuitBreaker> getRegisteredCircuitBreakers()
-
-