Package org.elasticsearch.common.breaker
Interface CircuitBreaker
- All Known Implementing Classes:
ChildMemoryCircuitBreaker
,NoopCircuitBreaker
public interface CircuitBreaker
Interface for an object that can be incremented, breaking after some
configured limit has been reached.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
static class
-
Field Summary
Modifier and TypeFieldDescriptionstatic String
The accounting breaker tracks things held in memory that is independent of the request lifecycle.static String
The fielddata breaker tracks data used for fielddata (on fields) as well as the id cached used for parent/child queries.static String
The in-flight request breaker tracks bytes allocated for reading and writing requests on the network layer.static String
The parent breaker is a sum of all the following breakers combined.static String
The request breaker tracks memory used for particular requests. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEstimateBytesAndMaybeBreak(long bytes, String label)
Add bytes to the breaker and trip if the that puts breaker over the limit.void
addWithoutBreaking(long bytes)
Add bytes to the circuit breaker without tripping.void
circuitBreak(String fieldName, long bytesNeeded)
Trip the circuit breakerlong
getLimit()
getName()
double
long
long
getUsed()
void
setLimitAndOverhead(long limit, double overhead)
sets the new limit and overhead values for the circuit breaker.
-
Field Details
-
PARENT
The parent breaker is a sum of all the following breakers combined. With this we allow a single breaker to have a significant amount of memory available while still having a "total" limit for all breakers. Note that it's not a "real" breaker in that it cannot be added to or subtracted from by itself.- See Also:
- Constant Field Values
-
FIELDDATA
The fielddata breaker tracks data used for fielddata (on fields) as well as the id cached used for parent/child queries.- See Also:
- Constant Field Values
-
REQUEST
The request breaker tracks memory used for particular requests. This includes allocations for things like the cardinality aggregation, and accounting for the number of buckets used in an aggregation request. Generally the amounts added to this breaker are released after a request is finished.- See Also:
- Constant Field Values
-
IN_FLIGHT_REQUESTS
The in-flight request breaker tracks bytes allocated for reading and writing requests on the network layer.- See Also:
- Constant Field Values
-
ACCOUNTING
The accounting breaker tracks things held in memory that is independent of the request lifecycle. This includes memory used by Lucene for segments.- See Also:
- Constant Field Values
-
-
Method Details
-
circuitBreak
Trip the circuit breaker- Parameters:
fieldName
- name of the field responsible for tripping the breakerbytesNeeded
- bytes asked for but unable to be allocated
-
addEstimateBytesAndMaybeBreak
Add bytes to the breaker and trip if the that puts breaker over the limit.- Parameters:
bytes
- number of bytes to addlabel
- thing requesting the bytes being added that is included in the exception if the breaker is tripped- Throws:
CircuitBreakingException
-
addWithoutBreaking
void addWithoutBreaking(long bytes)Add bytes to the circuit breaker without tripping. -
getUsed
long getUsed()- Returns:
- the currently used bytes the breaker is tracking
-
getLimit
long getLimit()- Returns:
- maximum number of bytes the circuit breaker can track before tripping
-
getOverhead
double getOverhead()- Returns:
- overhead of circuit breaker
-
getTrippedCount
long getTrippedCount()- Returns:
- the number of times the circuit breaker has been tripped
-
getName
String getName()- Returns:
- the name of the breaker
-
getDurability
CircuitBreaker.Durability getDurability()- Returns:
- whether a tripped circuit breaker will reset itself (transient) or requires manual intervention (permanent).
-
setLimitAndOverhead
void setLimitAndOverhead(long limit, double overhead)sets the new limit and overhead values for the circuit breaker. The resulting write should be readable by other threads.- Parameters:
limit
- the desired limitoverhead
- the desired overhead constant
-