Package org.elasticsearch.common.breaker
Class ChildMemoryCircuitBreaker
java.lang.Object
org.elasticsearch.common.breaker.ChildMemoryCircuitBreaker
- All Implemented Interfaces:
CircuitBreaker
Breaker that will check a parent's when incrementing
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.breaker.CircuitBreaker
CircuitBreaker.Durability, CircuitBreaker.Type -
Field Summary
Fields inherited from interface org.elasticsearch.common.breaker.CircuitBreaker
ACCOUNTING, FIELDDATA, IN_FLIGHT_REQUESTS, PARENT, REQUEST -
Constructor Summary
ConstructorsConstructorDescriptionChildMemoryCircuitBreaker(BreakerSettings settings, org.apache.logging.log4j.Logger logger, HierarchyCircuitBreakerService parent, String name)Create a circuit breaker that will break if the number of estimated bytes grows above the limit. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEstimateBytesAndMaybeBreak(long bytes, String label)Add a number of bytes, tripping the circuit breaker if the aggregated estimates are above the limit.voidaddWithoutBreaking(long bytes)Add an exact number of bytes, not checking for tripping the circuit breaker.voidcircuitBreak(String fieldName, long bytesNeeded)Method used to trip the breaker, delegates to the parent to determine whether to trip the breaker or notlonggetLimit()getName()doublelonglonggetUsed()voidsetLimitAndOverhead(long limit, double overhead)sets the new limit and overhead values for the circuit breaker.
-
Constructor Details
-
ChildMemoryCircuitBreaker
public ChildMemoryCircuitBreaker(BreakerSettings settings, org.apache.logging.log4j.Logger logger, HierarchyCircuitBreakerService parent, String name)Create a circuit breaker that will break if the number of estimated bytes grows above the limit. All estimations will be multiplied by the given overheadConstant. Uses the given oldBreaker to initialize the starting offset.- Parameters:
settings- settings to configure this breakerparent- parent circuit breaker service to delegate tripped breakers toname- the name of the breaker
-
-
Method Details
-
circuitBreak
Method used to trip the breaker, delegates to the parent to determine whether to trip the breaker or not- Specified by:
circuitBreakin interfaceCircuitBreaker- Parameters:
fieldName- name of the field responsible for tripping the breakerbytesNeeded- bytes asked for but unable to be allocated
-
addEstimateBytesAndMaybeBreak
Add a number of bytes, tripping the circuit breaker if the aggregated estimates are above the limit. Automatically trips the breaker if the memory limit is set to 0. Will never trip the breaker if the limit is set to -1, but can still be used to aggregate estimations.- Specified by:
addEstimateBytesAndMaybeBreakin interfaceCircuitBreaker- Parameters:
bytes- number of bytes to add to the breakerlabel- thing requesting the bytes being added that is included in the exception if the breaker is tripped- Throws:
CircuitBreakingException
-
addWithoutBreaking
public void addWithoutBreaking(long bytes)Add an exact number of bytes, not checking for tripping the circuit breaker. This bypasses the overheadConstant multiplication. Also does not check with the parent breaker to see if the parent limit has been exceeded.- Specified by:
addWithoutBreakingin interfaceCircuitBreaker- Parameters:
bytes- number of bytes to add to the breaker
-
getUsed
public long getUsed()- Specified by:
getUsedin interfaceCircuitBreaker- Returns:
- the number of aggregated "used" bytes so far
-
getLimit
public long getLimit()- Specified by:
getLimitin interfaceCircuitBreaker- Returns:
- the number of bytes that can be added before the breaker trips
-
getOverhead
public double getOverhead()- Specified by:
getOverheadin interfaceCircuitBreaker- Returns:
- the constant multiplier the breaker uses for aggregations
-
getTrippedCount
public long getTrippedCount()- Specified by:
getTrippedCountin interfaceCircuitBreaker- Returns:
- the number of times the breaker has been tripped
-
getName
- Specified by:
getNamein interfaceCircuitBreaker- Returns:
- the name of the breaker
-
getDurability
- Specified by:
getDurabilityin interfaceCircuitBreaker- Returns:
- whether a tripped circuit breaker will reset itself (transient) or requires manual intervention (permanent).
-
setLimitAndOverhead
public void setLimitAndOverhead(long limit, double overhead)Description copied from interface:CircuitBreakersets the new limit and overhead values for the circuit breaker. The resulting write should be readable by other threads.- Specified by:
setLimitAndOverheadin interfaceCircuitBreaker- Parameters:
limit- the desired limitoverhead- the desired overhead constant
-