Class MemoryCircuitBreaker
- java.lang.Object
-
- org.apache.solr.util.circuitbreaker.CircuitBreaker
-
- org.apache.solr.util.circuitbreaker.MemoryCircuitBreaker
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,NamedListInitializedPlugin
public class MemoryCircuitBreaker extends CircuitBreaker
Tracks the current JVM heap usage and triggers if a moving heap usage average over 30 seconds exceeds the defined percentage of the maximum heap size allocated to the JVM. Once the average memory usage goes below the threshold, it will start allowing queries again.The memory threshold is defined as a percentage of the maximum memory allocated -- see memThreshold in
solrconfig.xml
.
-
-
Constructor Summary
Constructors Modifier Constructor Description MemoryCircuitBreaker()
Creates an instance which averages over 6 samples during last 30 seconds.protected
MemoryCircuitBreaker(int numSamples, int sampleInterval)
Constructor that allows override of sample interval for which the memory usage is fetched.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
protected long
getAvgMemoryUsage()
String
getErrorMessage()
Get error message when the circuit breaker triggersboolean
isTripped()
Check if circuit breaker is tripped.MemoryCircuitBreaker
setThreshold(double thresholdValueInPercentage)
String
toString()
-
Methods inherited from class org.apache.solr.util.circuitbreaker.CircuitBreaker
getErrorCode, getRequestTypes, init, isWarnOnly, setRequestTypes, setWarnOnly
-
-
-
-
Constructor Detail
-
MemoryCircuitBreaker
public MemoryCircuitBreaker()
Creates an instance which averages over 6 samples during last 30 seconds.
-
MemoryCircuitBreaker
protected MemoryCircuitBreaker(int numSamples, int sampleInterval)
Constructor that allows override of sample interval for which the memory usage is fetched. This is provided for testing, not intended for general use because the average metric provider implementation is the same for all instances of the class.- Parameters:
numSamples
- number of samples to calculate average forsampleInterval
- interval between each sample
-
-
Method Detail
-
setThreshold
public MemoryCircuitBreaker setThreshold(double thresholdValueInPercentage)
-
isTripped
public boolean isTripped()
Description copied from class:CircuitBreaker
Check if circuit breaker is tripped.- Specified by:
isTripped
in classCircuitBreaker
-
getAvgMemoryUsage
protected long getAvgMemoryUsage()
-
getErrorMessage
public String getErrorMessage()
Description copied from class:CircuitBreaker
Get error message when the circuit breaker triggers- Specified by:
getErrorMessage
in classCircuitBreaker
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classCircuitBreaker
- Throws:
IOException
-
-