Class CPUCircuitBreaker

  • All Implemented Interfaces:
    Closeable, AutoCloseable, NamedListInitializedPlugin

    public class CPUCircuitBreaker
    extends CircuitBreaker
    Tracks current CPU usage and triggers if the specified threshold is breached.

    This circuit breaker gets the recent average CPU usage and uses that data to take a decision. We depend on OperatingSystemMXBean which does not allow a configurable interval of collection of data.

    • Constructor Detail

      • CPUCircuitBreaker

        public CPUCircuitBreaker​(SolrCore core)
    • Method Detail

      • init

        public void init​(org.apache.solr.common.util.NamedList<?> args)
        Description copied from interface: NamedListInitializedPlugin
        init will be called just once, immediately after creation.

        Source of the initialization arguments will typically be solrconfig.xml, but will ultimately depends on the plugin itself

        Specified by:
        init in interface NamedListInitializedPlugin
        Overrides:
        init in class CircuitBreaker
        Parameters:
        args - non-null list of initialization parameters (may be empty)
      • setThreshold

        public void setThreshold​(double thresholdValueInPercentage)
      • getCpuUsageThreshold

        public double getCpuUsageThreshold()
      • calculateLiveCPUUsage

        protected double calculateLiveCPUUsage()
        Calculate the CPU usage for the system in percentage.
        Returns:
        Percent CPU usage of -1 if value could not be obtained.