Class ChildMemoryCircuitBreaker

java.lang.Object
org.elasticsearch.common.breaker.ChildMemoryCircuitBreaker
All Implemented Interfaces:
CircuitBreaker

public class ChildMemoryCircuitBreaker
extends java.lang.Object
implements CircuitBreaker
Breaker that will check a parent's when incrementing
  • Constructor Details

    • ChildMemoryCircuitBreaker

      public ChildMemoryCircuitBreaker​(BreakerSettings settings, org.apache.logging.log4j.Logger logger, HierarchyCircuitBreakerService parent, java.lang.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. This breaker starts with 0 bytes used.
      Parameters:
      settings - settings to configure this breaker
      parent - parent circuit breaker service to delegate tripped breakers to
      name - the name of the breaker
    • ChildMemoryCircuitBreaker

      public ChildMemoryCircuitBreaker​(BreakerSettings settings, ChildMemoryCircuitBreaker oldBreaker, org.apache.logging.log4j.Logger logger, HierarchyCircuitBreakerService parent, java.lang.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 breaker
      parent - parent circuit breaker service to delegate tripped breakers to
      name - the name of the breaker
      oldBreaker - the previous circuit breaker to inherit the used value from (starting offset)
  • Method Details

    • circuitBreak

      public void circuitBreak​(java.lang.String fieldName, long bytesNeeded)
      Method used to trip the breaker, delegates to the parent to determine whether to trip the breaker or not
      Specified by:
      circuitBreak in interface CircuitBreaker
      Parameters:
      fieldName - name of the field responsible for tripping the breaker
      bytesNeeded - bytes asked for but unable to be allocated
    • addEstimateBytesAndMaybeBreak

      public double addEstimateBytesAndMaybeBreak​(long bytes, java.lang.String label) throws CircuitBreakingException
      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 < 0, but can still be used to aggregate estimations.
      Specified by:
      addEstimateBytesAndMaybeBreak in interface CircuitBreaker
      Parameters:
      bytes - number of bytes to add to the breaker
      label - string label describing the bytes being added
      Returns:
      number of "used" bytes so far
      Throws:
      CircuitBreakingException
    • addWithoutBreaking

      public long 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:
      addWithoutBreaking in interface CircuitBreaker
      Parameters:
      bytes - number of bytes to add to the breaker
      Returns:
      number of "used" bytes so far
    • getUsed

      public long getUsed()
      Specified by:
      getUsed in interface CircuitBreaker
      Returns:
      the number of aggregated "used" bytes so far
    • getLimit

      public long getLimit()
      Specified by:
      getLimit in interface CircuitBreaker
      Returns:
      the number of bytes that can be added before the breaker trips
    • getOverhead

      public double getOverhead()
      Specified by:
      getOverhead in interface CircuitBreaker
      Returns:
      the constant multiplier the breaker uses for aggregations
    • getTrippedCount

      public long getTrippedCount()
      Specified by:
      getTrippedCount in interface CircuitBreaker
      Returns:
      the number of times the breaker has been tripped
    • getName

      public java.lang.String getName()
      Specified by:
      getName in interface CircuitBreaker
      Returns:
      the name of the breaker
    • getDurability

      public CircuitBreaker.Durability getDurability()
      Specified by:
      getDurability in interface CircuitBreaker
      Returns:
      whether a tripped circuit breaker will reset itself (transient) or requires manual intervention (permanent).