Class CircuitBreaker
- java.lang.Object
-
- org.apache.solr.util.circuitbreaker.CircuitBreaker
-
- All Implemented Interfaces:
Closeable,AutoCloseable,NamedListInitializedPlugin
- Direct Known Subclasses:
CircuitBreakerManager,CPUCircuitBreaker,LoadAverageCircuitBreaker,MemoryCircuitBreaker
public abstract class CircuitBreaker extends Object implements NamedListInitializedPlugin, Closeable
Default base class to define circuit breaker plugins for Solr. Still experimental, may changeThere are two (typical) ways to use circuit breakers:
- Have them checked at admission control by default (use CircuitBreakerRegistry for the same).
- Use the circuit breaker in a specific code path(s).
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Constructor Summary
Constructors Constructor Description CircuitBreaker()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclose()static org.apache.solr.common.SolrException.ErrorCodegetErrorCode(List<CircuitBreaker> trippedCircuitBreakers)Deprecated.Remove in 10.0abstract StringgetErrorMessage()Get error message when the circuit breaker triggersSet<org.apache.solr.client.solrj.SolrRequest.SolrRequestType>getRequestTypes()voidinit(org.apache.solr.common.util.NamedList<?> args)initwill be called just once, immediately after creation.abstract booleanisTripped()Check if circuit breaker is tripped.booleanisWarnOnly()voidsetRequestTypes(List<String> requestTypes)Set the request types for which this circuit breaker should be checked.voidsetWarnOnly(boolean warnOnly)
-
-
-
Method Detail
-
init
public void init(org.apache.solr.common.util.NamedList<?> args)
Description copied from interface:NamedListInitializedPlugininitwill 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:
initin interfaceNamedListInitializedPlugin- Parameters:
args- non-null list of initialization parameters (may be empty)
-
isTripped
public abstract boolean isTripped()
Check if circuit breaker is tripped.
-
getErrorMessage
public abstract String getErrorMessage()
Get error message when the circuit breaker triggers
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
setRequestTypes
public void setRequestTypes(List<String> requestTypes)
Set the request types for which this circuit breaker should be checked. If not called, the circuit breaker will be checked for theSolrRequest.SolrRequestType.QUERYrequest type only.- Parameters:
requestTypes- list of strings representing request types- Throws:
IllegalArgumentException- if the request type is not valid
-
setWarnOnly
public void setWarnOnly(boolean warnOnly)
-
isWarnOnly
public boolean isWarnOnly()
-
getRequestTypes
public Set<org.apache.solr.client.solrj.SolrRequest.SolrRequestType> getRequestTypes()
-
getErrorCode
@Deprecated(since="9.4") public static org.apache.solr.common.SolrException.ErrorCode getErrorCode(List<CircuitBreaker> trippedCircuitBreakers)
Deprecated.Remove in 10.0Return the proper error code to use in exception. For legacy use ofCircuitBreakerwe return 503 for backward compatibility, else return 429.
-
-