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


##########
solr/core/src/java/org/apache/solr/util/circuitbreaker/CircuitBreakerManager.java:
##########
@@ -17,163 +17,96 @@
 
 package org.apache.solr.util.circuitbreaker;
 
-import com.google.common.annotations.VisibleForTesting;
-import java.util.ArrayList;
-import java.util.List;
+import java.lang.invoke.MethodHandles;
 import org.apache.solr.common.util.NamedList;
-import org.apache.solr.core.PluginInfo;
-import org.apache.solr.util.plugin.PluginInfoInitialized;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
- * Manages all registered circuit breaker instances. Responsible for a 
holistic view of whether a
- * circuit breaker has tripped or not.
+ * Single CB that registers both Mem and CPU CB. This is only for backward 
compatibility with the
+ * 9.x versions prior to 9.4.
  *
- * <p>There are two typical ways of using this class's instance: 1. Check if 
any circuit breaker has
- * triggered -- and know which circuit breaker has triggered. 2. Get an 
instance of a specific
- * circuit breaker and perform checks.
- *
- * <p>It is a good practice to register new circuit breakers here if you want 
them checked for every
- * request.
- *
- * <p>NOTE: The current way of registering new default circuit breakers is 
minimal and not a long
- * term solution. There will be a follow up with a SIP for a schema API design.
+ * @deprecated Use individual Circuit Breakers instead
  */
-public class CircuitBreakerManager implements PluginInfoInitialized {
-  // Class private to potentially allow "family" of circuit breakers to be 
enabled or disabled
-  private final boolean enableCircuitBreakerManager;
-
-  private final List<CircuitBreaker> circuitBreakerList = new ArrayList<>();
-
-  public CircuitBreakerManager(final boolean enableCircuitBreakerManager) {
-    this.enableCircuitBreakerManager = enableCircuitBreakerManager;
+@Deprecated(since = "9.4")
+public class CircuitBreakerManager extends CircuitBreaker {
+  private static final Logger log = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+  private boolean cpuEnabled;
+  private boolean memEnabled;
+  private int memThreshold = 100;
+  private int cpuThreshold = 100;
+  private MemoryCircuitBreaker memCB;
+  private CPUCircuitBreaker cpuCB;
+
+  public CircuitBreakerManager() {
+    super();
   }
 
   @Override
-  public void init(PluginInfo pluginInfo) {
-    CircuitBreaker.CircuitBreakerConfig circuitBreakerConfig = 
buildCBConfig(pluginInfo);
-
-    // Install the default circuit breakers
-    CircuitBreaker memoryCircuitBreaker = new 
MemoryCircuitBreaker(circuitBreakerConfig);
-    CircuitBreaker cpuCircuitBreaker = new 
CPUCircuitBreaker(circuitBreakerConfig);
-
-    register(memoryCircuitBreaker);
-    register(cpuCircuitBreaker);
-  }
-
-  public void register(CircuitBreaker circuitBreaker) {
-    circuitBreakerList.add(circuitBreaker);
+  public boolean isTripped() {
+    return memEnabled && memCB.isTripped() || cpuEnabled && cpuCB.isTripped();

Review Comment:
   precommit says 
`/home/runner/work/solr/solr/solr/core/src/java/org/apache/solr/util/circuitbreaker/CircuitBreakerManager.java:47:
 warning: [OperatorPrecedence] Use grouping parenthesis to make the operator 
precedence explicit` i.e. presumably that means this:
   ```suggestion
       return (memEnabled && memCB.isTripped()) || (cpuEnabled && 
cpuCB.isTripped());
   ```



-- 
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