public class MemoryCircuitBreaker extends java.lang.Object implements CircuitBreaker
CircuitBreaker.TypeFIELDDATA, IN_FLIGHT_REQUESTS, PARENT, REQUEST| Constructor and Description |
|---|
MemoryCircuitBreaker(ByteSizeValue limit,
double overheadConstant,
org.apache.logging.log4j.Logger logger)
Create a circuit breaker that will break if the number of estimated
bytes grows above the limit.
|
MemoryCircuitBreaker(ByteSizeValue limit,
double overheadConstant,
MemoryCircuitBreaker oldBreaker,
org.apache.logging.log4j.Logger logger)
Create a circuit breaker that will break if the number of estimated
bytes grows above the limit.
|
| Modifier and Type | Method and Description |
|---|---|
double |
addEstimateBytesAndMaybeBreak(long bytes,
java.lang.String label)
Add a number of bytes, tripping the circuit breaker if the aggregated
estimates are above the limit.
|
long |
addWithoutBreaking(long bytes)
Add an exact number of bytes, not checking for tripping the
circuit breaker.
|
void |
circuitBreak(java.lang.String fieldName,
long bytesNeeded)
Method used to trip the breaker
|
long |
getLimit() |
java.lang.String |
getName() |
double |
getOverhead() |
long |
getTrippedCount() |
long |
getUsed() |
public MemoryCircuitBreaker(ByteSizeValue limit, double overheadConstant, org.apache.logging.log4j.Logger logger)
limit - circuit breaker limitoverheadConstant - constant multiplier for byte estimationspublic MemoryCircuitBreaker(ByteSizeValue limit, double overheadConstant, MemoryCircuitBreaker oldBreaker, org.apache.logging.log4j.Logger logger)
limit - circuit breaker limitoverheadConstant - constant multiplier for byte estimationsoldBreaker - the previous circuit breaker to inherit the used value from (starting offset)public void circuitBreak(java.lang.String fieldName,
long bytesNeeded)
throws CircuitBreakingException
circuitBreak in interface CircuitBreakerfieldName - name of the field responsible for tripping the breakerbytesNeeded - bytes asked for but unable to be allocatedCircuitBreakingExceptionpublic double addEstimateBytesAndMaybeBreak(long bytes,
java.lang.String label)
throws CircuitBreakingException
addEstimateBytesAndMaybeBreak in interface CircuitBreakerbytes - number of bytes to add to the breakerlabel - string label describing the bytes being addedCircuitBreakingExceptionpublic long addWithoutBreaking(long bytes)
addWithoutBreaking in interface CircuitBreakerbytes - number of bytes to add to the breakerpublic long getUsed()
getUsed in interface CircuitBreakerpublic long getLimit()
getLimit in interface CircuitBreakerpublic double getOverhead()
getOverhead in interface CircuitBreakerpublic long getTrippedCount()
getTrippedCount in interface CircuitBreakerpublic java.lang.String getName()
getName in interface CircuitBreaker