Apache Solr open-source search software
add aggregateNodeLevelMetricsEnabled for updatehandler metrics (#1630)
Noble Paul67e177155877
diff --git a/solr/core/src/java/org/apache/solr/core/SolrConfig.java b/solr/core/src/java/org/apache/solr/core/SolrConfig.javaindex fd9b05f86cf..c976f1a8c7f 100644--- a/solr/core/src/java/org/apache/solr/core/SolrConfig.java+++ b/solr/core/src/java/org/apache/solr/core/SolrConfig.java@@ -586,17 +586,7 @@ public class SolrConfig implements MapSerializable {}protected UpdateHandlerInfo loadUpdatehandlerInfo() {- ConfigNode updateHandler = get("updateHandler");- ConfigNode autoCommit = updateHandler.get("autoCommit");- return new UpdateHandlerInfo(- updateHandler.attr("class"),- autoCommit.get("maxDocs").intVal(-1),- autoCommit.get("maxTime").intVal(-1),- convertHeapOptionStyleConfigStringToBytes(autoCommit.get("maxSize").txt()),- autoCommit.get("openSearcher").boolVal(true),- updateHandler.get("autoSoftCommit").get("maxDocs").intVal(-1),- updateHandler.get("autoSoftCommit").get("maxTime").intVal(-1),- updateHandler.get("commitWithin").get("softCommit").boolVal(true));+ return new UpdateHandlerInfo(get("updateHandler"));}/**@@ -815,6 +805,7 @@ public class SolrConfig implements MapSerializable {public final long autoCommitMaxSizeBytes;public final boolean openSearcher; // is opening a new searcher part of hard autocommit?public final boolean commitWithinSoftCommit;+ public final boolean aggregateNodeLevelMetricsEnabled;/*** @param autoCommmitMaxDocs set -1 as default@@ -840,6 +831,23 @@ public class SolrConfig implements MapSerializable {this.autoSoftCommmitMaxTime = autoSoftCommmitMaxTime;this.commitWithinSoftCommit = commitWithinSoftCommit;+ this.aggregateNodeLevelMetricsEnabled = false;+ }++ public UpdateHandlerInfo(ConfigNode updateHandler) {+ ConfigNode autoCommit = updateHandler.get("autoCommit");+ this.className = updateHandler.attr("class");+ this.autoCommmitMaxDocs = autoCommit.get("maxDocs").intVal(-1);+ this.autoCommmitMaxTime = autoCommit.get("maxTime").intVal(-1);+ this.autoCommitMaxSizeBytes =+ convertHeapOptionStyleConfigStringToBytes(autoCommit.get("maxSize").txt());+ this.openSearcher = autoCommit.get("openSearcher").boolVal(true);+ this.autoSoftCommmitMaxDocs = updateHandler.get("autoSoftCommit").get("maxDocs").intVal(-1);+ this.autoSoftCommmitMaxTime = updateHandler.get("autoSoftCommit").get("maxTime").intVal(-1);+ this.commitWithinSoftCommit =+ updateHandler.get("commitWithin").get("softCommit").boolVal(true);+ this.aggregateNodeLevelMetricsEnabled =+ updateHandler.boolAttr("aggregateNodeLevelMetricsEnabled", false);}@Overridediff --git a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.javaindex 772779a1926..e39f23751e1 100644--- a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java+++ b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java@@ -50,6 +50,9 @@ import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.NamedList;import org.apache.solr.core.SolrConfig.UpdateHandlerInfo;import org.apache.solr.core.SolrCore;+import org.apache.solr.core.SolrInfoBean;+import org.apache.solr.metrics.SolrDelegateRegistryMetricsContext;+import org.apache.solr.metrics.SolrMetricManager;import org.apache.solr.metrics.SolrMetricProducer;import org.apache.solr.metrics.SolrMetricsContext;import org.apache.solr.request.LocalSolrQueryRequest;@@ -196,7 +199,16 @@ public class DirectUpdateHandler2 extends UpdateHandler@Overridepublic void initializeMetrics(SolrMetricsContext parentContext, String scope) {- solrMetricsContext = parentContext.getChildContext(this);+ if (core.getSolrConfig().getUpdateHandlerInfo().aggregateNodeLevelMetricsEnabled) {+ this.solrMetricsContext =+ new SolrDelegateRegistryMetricsContext(+ parentContext.getMetricManager(),+ parentContext.getRegistryName(),+ SolrMetricProducer.getUniqueMetricTag(this, parentContext.getTag()),+ SolrMetricManager.getRegistryName(SolrInfoBean.Group.node));+ } else {+ this.solrMetricsContext = parentContext.getChildContext(this);+ }commitCommands = solrMetricsContext.meter("commits", getCategory().toString(), scope);solrMetricsContext.gauge(() -> commitTracker.getCommitCount(), true, "autoCommits", getCategory().toString(), scope);