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 void
close()
static org.apache.solr.common.SolrException.ErrorCode
getErrorCode(List<CircuitBreaker> trippedCircuitBreakers)
Deprecated.Remove in 10.0abstract String
getErrorMessage()
Get error message when the circuit breaker triggersSet<org.apache.solr.client.solrj.SolrRequest.SolrRequestType>
getRequestTypes()
void
init(org.apache.solr.common.util.NamedList<?> args)
init
will be called just once, immediately after creation.abstract boolean
isTripped()
Check if circuit breaker is tripped.boolean
isWarnOnly()
void
setRequestTypes(List<String> requestTypes)
Set the request types for which this circuit breaker should be checked.void
setWarnOnly(boolean warnOnly)
-
-
-
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
- 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:
close
in interfaceAutoCloseable
- Specified by:
close
in 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.QUERY
request 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 ofCircuitBreaker
we return 503 for backward compatibility, else return 429.
-
-