From 28400bb72fa4bf06fbf7824b08a79da2ee3b55b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B8ydahl?= Date: Sat, 9 Dec 2023 16:38:27 +0100 Subject: [PATCH] SOLR-15960: Remove explicit var conversion of global circuit breaker vars such as SOLR_CIRCUITBREAKER_UPDATE_CPU --- solr/bin/solr | 20 ------------------- .../CircuitBreakerRegistry.java | 5 +++-- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/solr/bin/solr b/solr/bin/solr index ff96aff4784..7a83cfa82a6 100755 --- a/solr/bin/solr +++ b/solr/bin/solr @@ -1414,26 +1414,6 @@ if [ "${SOLR_ENABLE_STREAM_BODY:-false}" == "true" ]; then SCRIPT_SOLR_OPTS+=("-Dsolr.enableStreamBody=true") fi -# Parse global circuit breaker env vars and convert to dot separated, lowercase properties -if [ -n "${SOLR_CIRCUITBREAKER_UPDATE_CPU:-}" ]; then - SOLR_OPTS+=("-Dsolr.circuitbreaker.update.cpu=$SOLR_CIRCUITBREAKER_UPDATE_CPU") -fi -if [ -n "${SOLR_CIRCUITBREAKER_UPDATE_MEM:-}" ]; then - SOLR_OPTS+=("-Dsolr.circuitbreaker.update.mem=$SOLR_CIRCUITBREAKER_UPDATE_MEM") -fi -if [ -n "${SOLR_CIRCUITBREAKER_UPDATE_LOADAVG:-}" ]; then - SOLR_OPTS+=("-Dsolr.circuitbreaker.update.loadavg=$SOLR_CIRCUITBREAKER_UPDATE_LOADAVG") -fi -if [ -n "${SOLR_CIRCUITBREAKER_QUERY_CPU:-}" ]; then - SOLR_OPTS+=("-Dsolr.circuitbreaker.query.cpu=$SOLR_CIRCUITBREAKER_QUERY_CPU") -fi -if [ -n "${SOLR_CIRCUITBREAKER_QUERY_MEM:-}" ]; then - SOLR_OPTS+=("-Dsolr.circuitbreaker.query.mem=$SOLR_CIRCUITBREAKER_QUERY_MEM") -fi -if [ -n "${SOLR_CIRCUITBREAKER_QUERY_LOADAVG:-}" ]; then - SOLR_OPTS+=("-Dsolr.circuitbreaker.query.loadavg=$SOLR_CIRCUITBREAKER_QUERY_LOADAVG") -fi - : ${SOLR_SERVER_DIR:=$DEFAULT_SERVER_DIR} if [ ! -e "$SOLR_SERVER_DIR" ]; then diff --git a/solr/core/src/java/org/apache/solr/util/circuitbreaker/CircuitBreakerRegistry.java b/solr/core/src/java/org/apache/solr/util/circuitbreaker/CircuitBreakerRegistry.java index 14e9ee2bb47..b1782867cce 100644 --- a/solr/core/src/java/org/apache/solr/util/circuitbreaker/CircuitBreakerRegistry.java +++ b/solr/core/src/java/org/apache/solr/util/circuitbreaker/CircuitBreakerRegistry.java @@ -34,6 +34,7 @@ import org.apache.solr.client.solrj.SolrRequest.SolrRequestType; import org.apache.solr.common.SolrException; import org.apache.solr.core.CoreContainer; +import org.apache.solr.util.EnvUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,8 +69,8 @@ public CircuitBreakerRegistry(CoreContainer coreContainer) { private static void initGlobal(CoreContainer coreContainer) { // Read system properties to register global circuit breakers for update and query: // Example: solr.circuitbreaker.update.cpu = 50 - System.getProperties().keySet().stream() - .map(k -> SYSPROP_REGEX.matcher(k.toString())) + EnvUtils.getProps().keySet().stream() + .map(SYSPROP_REGEX::matcher) .filter(Matcher::matches) .collect(Collectors.groupingBy(m -> m.group(2) + ":" + System.getProperty(m.group(0)))) .forEach(