cpoerschke commented on code in PR #96:
URL: https://github.com/apache/solr/pull/96#discussion_r1310547379


##########
solr/core/src/java/org/apache/solr/util/circuitbreaker/CPUCircuitBreaker.java:
##########
@@ -17,54 +17,49 @@
 
 package org.apache.solr.util.circuitbreaker;
 
+import com.codahale.metrics.Gauge;
+import com.codahale.metrics.Metric;
 import java.lang.invoke.MethodHandles;
-import java.lang.management.ManagementFactory;
-import java.lang.management.OperatingSystemMXBean;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.metrics.SolrMetricManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * Tracks current CPU usage and triggers if the specified threshold is 
breached.
  *
- * <p>This circuit breaker gets the average CPU load over the last minute and 
uses that data to take
- * a decision. We depend on OperatingSystemMXBean which does not allow a 
configurable interval of
- * collection of data. //TODO: Use Codahale Meter to calculate the value 
locally.
- *
- * <p>The configuration to define which mode to use and the trigger threshold 
are defined in
- * solrconfig.xml
+ * <p>This circuit breaker gets the recent average CPU usage and uses that 
data to take a decision.
+ * We depend on OperatingSystemMXBean which does not allow a configurable 
interval of collection of
+ * data.
  */
 public class CPUCircuitBreaker extends CircuitBreaker {
   private static final Logger log = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-  private static final OperatingSystemMXBean operatingSystemMXBean =
-      ManagementFactory.getOperatingSystemMXBean();
 
+  private static boolean warningLogged = false;

Review Comment:
   edge case: could the circuit breaker be used from multiple threads and so 
`boolean` here needs to be supportive of potentially concurrent access?



##########
solr/solr-ref-guide/modules/deployment-guide/pages/circuit-breakers.adoc:
##########
@@ -70,7 +83,30 @@ To enable and configure the CPU utilization based circuit 
breaker:
 </circuitBreaker>
 ----
 
-The `threshold` is defined in units of CPU utilization.
+The triggering threshold is defined in percent CPU usage. A value of "0" maps 
to 0% usage
+and a value of "100" maps to 100% usage.  The example above will trip when the 
CPU usage is
+equal to or greater than 75%:.

Review Comment:
   ```suggestion
   equal to or greater than 75%:
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to