Package org.apache.solr.client.solrj.impl

# Class StallDetection

java.lang.Object
org.apache.solr.client.solrj.impl.StallDetection

public class StallDetection extends Object
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

Constructors
Constructor
Description
`StallDetection(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 Type
Method
Description
`long`
`getProcessedCount()`
Gets the current processed count.
`long`
`getStallTimeMillis()`
Gets the stall time in milliseconds.
`void`
`incrementProcessedCount()`
Increments the processed count.
`void`
`resetStallTimer()`
Resets the stall timer.
`void`
`stallCheck()`
Checks if request processing has stalled.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### StallDetection

public StallDetection(long stallTimeMillis, IntSupplier queueSizeSupplier)
Creates a new StallDetection instance.

Parameters:
  `stallTimeMillis` - The time in milliseconds after which to consider processing stalled
  `queueSizeSupplier` - A supplier that returns the current queue size

### StallDetection

public StallDetection(long stallTimeMillis, IntSupplier queueSizeSupplier, TimeSource timeSource)
Creates a new StallDetection instance with a custom time source.

Parameters:
  `stallTimeMillis` - The time in milliseconds after which to consider processing stalled
  `queueSizeSupplier` - A supplier that returns the current queue size
  `timeSource` - 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

public void stallCheck() throws IOException
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.