janhoy commented on code in PR #1905:
URL: https://github.com/apache/solr/pull/1905#discussion_r1319878223


##########
solr/core/src/java/org/apache/solr/util/circuitbreaker/MemoryCircuitBreaker.java:
##########
@@ -43,8 +46,34 @@ public class MemoryCircuitBreaker extends CircuitBreaker {
   private static final ThreadLocal<Long> seenMemory = 
ThreadLocal.withInitial(() -> 0L);
   private static final ThreadLocal<Long> allowedMemory = 
ThreadLocal.withInitial(() -> 0L);
 
+  /** Creates an instance which averages over 6 samples during last 30 
seconds. */
   public MemoryCircuitBreaker() {
+    this(6, 5);
+  }
+
+  /**
+   * Constructor that allows override of sample interval for which the memory 
usage is fetched. This
+   * is provided for testing, not intended for general use.
+   *
+   * @param numSamples number of samples to calculate average for
+   * @param sampleInterval interval between each sample
+   */
+  protected MemoryCircuitBreaker(int numSamples, int sampleInterval) {
     super();
+    if (averagingMetricProvider == null || 
averagingMetricProvider.getRefcount() == 0) {
+      averagingMetricProvider =

Review Comment:
   It's my first attempt using `RefCounted` API, so I may be holding it wrong.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to