public class MemoryCircuitBreaker extends Object implements CircuitBreaker
CircuitBreaker.Type
FIELDDATA, PARENT, REQUEST
Constructor and Description |
---|
MemoryCircuitBreaker(ByteSizeValue limit,
double overheadConstant,
ESLogger 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,
ESLogger 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,
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(String fieldName,
long bytesNeeded)
Method used to trip the breaker
|
long |
getLimit() |
String |
getName() |
double |
getOverhead() |
long |
getTrippedCount() |
long |
getUsed() |
public MemoryCircuitBreaker(ByteSizeValue limit, double overheadConstant, ESLogger logger)
limit
- circuit breaker limitoverheadConstant
- constant multiplier for byte estimationspublic MemoryCircuitBreaker(ByteSizeValue limit, double overheadConstant, MemoryCircuitBreaker oldBreaker, ESLogger 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(String fieldName, long bytesNeeded) throws CircuitBreakingException
circuitBreak
in interface CircuitBreaker
fieldName
- name of the field responsible for tripping the breakerbytesNeeded
- bytes asked for but unable to be allocatedCircuitBreakingException
public double addEstimateBytesAndMaybeBreak(long bytes, String label) throws CircuitBreakingException
addEstimateBytesAndMaybeBreak
in interface CircuitBreaker
bytes
- number of bytes to add to the breakerlabel
- string label describing the bytes being addedCircuitBreakingException
public long addWithoutBreaking(long bytes)
addWithoutBreaking
in interface CircuitBreaker
bytes
- number of bytes to add to the breakerpublic long getUsed()
getUsed
in interface CircuitBreaker
public long getLimit()
getLimit
in interface CircuitBreaker
public double getOverhead()
getOverhead
in interface CircuitBreaker
public long getTrippedCount()
getTrippedCount
in interface CircuitBreaker
public String getName()
getName
in interface CircuitBreaker
Copyright © 2009–2016. All rights reserved.