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

    Nested Classes
    Modifier and Type Interface Description
    static class  CircuitBreaker.Durability  
    static class  CircuitBreaker.Type  
  • Field Summary

    Fields
    Modifier and Type Field Description
    static java.lang.String ACCOUNTING
    The accounting breaker tracks things held in memory that is independent of the request lifecycle.
    static java.lang.String FIELDDATA
    The fielddata breaker tracks data used for fielddata (on fields) as well as the id cached used for parent/child queries.
    static java.lang.String IN_FLIGHT_REQUESTS
    The in-flight request breaker tracks bytes allocated for reading and writing requests on the network layer.
    static java.lang.String PARENT
    The parent breaker is a sum of all the following breakers combined.
    static java.lang.String REQUEST
    The request breaker tracks memory used for particular requests.
  • Method Summary

    Modifier and Type Method Description
    void addEstimateBytesAndMaybeBreak​(long bytes, java.lang.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​(java.lang.String fieldName, long bytesNeeded)
    Trip the circuit breaker
    CircuitBreaker.Durability getDurability()  
    long getLimit()  
    java.lang.String getName()  
    double getOverhead()  
    long getTrippedCount()  
    long getUsed()  
    void setLimitAndOverhead​(long limit, double overhead)
    sets the new limit and overhead values for the circuit breaker.
  • Field Details

    • PARENT

      static final java.lang.String 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

      static final java.lang.String 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

      static final java.lang.String 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

      static final java.lang.String 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

      static final java.lang.String 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

      void circuitBreak​(java.lang.String fieldName, long bytesNeeded)
      Trip the circuit breaker
      Parameters:
      fieldName - name of the field responsible for tripping the breaker
      bytesNeeded - bytes asked for but unable to be allocated
    • addEstimateBytesAndMaybeBreak

      void addEstimateBytesAndMaybeBreak​(long bytes, java.lang.String label) throws CircuitBreakingException
      Add bytes to the breaker and trip if the that puts breaker over the limit.
      Parameters:
      bytes - number of bytes to add
      label - 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

      java.lang.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 limit
      overhead - the desired overhead constant