Class StallDetection
java.lang.Object
org.apache.solr.client.solrj.impl.StallDetection
Utility class for detecting stalls in request processing.
This class is used by ConcurrentUpdateBaseSolrClient to detect when request processing
has stalled, which can happen if the server is unresponsive or if there's a problem with the
connection.
-
Constructor Summary
ConstructorsConstructorDescriptionStallDetection(long stallTimeMillis, IntSupplier queueSizeSupplier) Creates a new StallDetection instance.StallDetection(long stallTimeMillis, IntSupplier queueSizeSupplier, TimeSource timeSource) Creates a new StallDetection instance with a custom time source. -
Method Summary
Modifier and TypeMethodDescriptionlongGets the current processed count.longGets the stall time in milliseconds.voidIncrements the processed count.voidResets the stall timer.voidChecks if request processing has stalled.
-
Constructor Details
-
StallDetection
Creates a new StallDetection instance.- Parameters:
stallTimeMillis- The time in milliseconds after which to consider processing stalledqueueSizeSupplier- A supplier that returns the current queue size
-
StallDetection
Creates a new StallDetection instance with a custom time source.- Parameters:
stallTimeMillis- The time in milliseconds after which to consider processing stalledqueueSizeSupplier- A supplier that returns the current queue sizetimeSource- The time source to use for time measurements
-
-
Method Details
-
incrementProcessedCount
public void incrementProcessedCount()Increments the processed count.This should be called whenever a request is successfully processed.
-
stallCheck
Checks if request processing has stalled.This method should be called periodically to check if request processing has stalled. If the queue is not empty and the processed count hasn't changed since the last check, a timer is started. If the timer exceeds the stall time, an IOException is thrown.
This method will never throw an exception if the queue is empty.
- Throws:
IOException- if request processing has stalled
-
getProcessedCount
public long getProcessedCount()Gets the current processed count.- Returns:
- the current processed count
-
getStallTimeMillis
public long getStallTimeMillis()Gets the stall time in milliseconds.- Returns:
- the stall time in milliseconds
-
resetStallTimer
public void resetStallTimer()Resets the stall timer.This can be useful if you know that processing hasn't actually stalled even though the processed count hasn't changed.
-