From 36eae571636426148ea25028c5b0e0149ce45f88 Mon Sep 17 00:00:00 2001 From: Andrzej Bialecki Date: Mon, 17 Sep 2018 14:40:36 +0200 Subject: [PATCH] SOLR-12765: Incorrect format of JMX cache stats. --- solr/CHANGES.txt | 2 ++ .../solr/metrics/reporters/jmx/JmxMetricsReporter.java | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index e7739045217..3f7871952a1 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -355,6 +355,8 @@ Bug Fixes * SOLR-11836: FacetStream works with bucketSizeLimit of -1 which will fetch all the buckets. (Alfonso Muñoz-Pomer Fuentes, Amrit Sarkar via Varun Thacker) +* SOLR-12765: Incorrect format of JMX cache stats. (Bojan Smid, ab) + Optimizations ---------------------- diff --git a/solr/core/src/java/org/apache/solr/metrics/reporters/jmx/JmxMetricsReporter.java b/solr/core/src/java/org/apache/solr/metrics/reporters/jmx/JmxMetricsReporter.java index ebf47e6acbb..f7a0127cac6 100644 --- a/solr/core/src/java/org/apache/solr/metrics/reporters/jmx/JmxMetricsReporter.java +++ b/solr/core/src/java/org/apache/solr/metrics/reporters/jmx/JmxMetricsReporter.java @@ -50,6 +50,7 @@ import com.codahale.metrics.ObjectNameFactory; import com.codahale.metrics.Reporter; import com.codahale.metrics.Timer; import org.apache.solr.metrics.MetricsMap; +import org.apache.solr.metrics.SolrMetricManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -558,9 +559,12 @@ public class JmxMetricsReporter implements Reporter, Closeable { try { if (filter.matches(name, gauge)) { final ObjectName objectName = createName("gauges", name); - if (gauge instanceof MetricsMap) { - ((MetricsMap)gauge).setAttribute(new Attribute(INSTANCE_TAG, tag)); - registerMBean(gauge, objectName); + if (gauge instanceof SolrMetricManager.GaugeWrapper && + ((SolrMetricManager.GaugeWrapper)gauge).getGauge() instanceof MetricsMap) { + MetricsMap mm = (MetricsMap)((SolrMetricManager.GaugeWrapper)gauge).getGauge(); + mm.setAttribute(new Attribute(INSTANCE_TAG, tag)); + // don't wrap it in a JmxGauge, it already supports all necessary JMX attributes + registerMBean(mm, objectName); } else { registerMBean(new JmxGauge(gauge, objectName, tag), objectName); }