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.protectedMemoryCircuitBreaker(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 voidclose()protected longgetAvgMemoryUsage()StringgetErrorMessage()Get error message when the circuit breaker triggersbooleanisTripped()Check if circuit breaker is tripped.MemoryCircuitBreakersetThreshold(double thresholdValueInPercentage)StringtoString()-
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:CircuitBreakerCheck if circuit breaker is tripped.- Specified by:
isTrippedin classCircuitBreaker
-
getAvgMemoryUsage
protected long getAvgMemoryUsage()
-
getErrorMessage
public String getErrorMessage()
Description copied from class:CircuitBreakerGet error message when the circuit breaker triggers- Specified by:
getErrorMessagein classCircuitBreaker
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classCircuitBreaker- Throws:
IOException
-
-