From 3959c53eafc9e5cc55c48cbf6a5382b0f9bffa75 Mon Sep 17 00:00:00 2001 From: Christine Poerschke Date: Fri, 11 Aug 2017 12:34:52 +0100 Subject: [PATCH] SOLR-11195: Require class attribute for shard and cluster metric reporter configuration. --- solr/CHANGES.txt | 8 +++++++- .../apache/solr/metrics/SolrMetricManager.java | 18 ++++++------------ .../src/test-files/solr/solr-solrreporter.xml | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 5cfd0ea41cf..86eb24721c4 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -52,7 +52,11 @@ Detailed Change List Upgrade Notes ---------------------- -(No Notes) +* SOLR-11195: shard and cluster metric reporter configuration now requires a class attribute. + If a reporter configures the group="shard" attribute then please also configure the + class="org.apache.solr.metrics.reporters.solr.SolrShardReporter" attribute. + If a reporter configures the group="cluster" attribute then please also configure the + class="org.apache.solr.metrics.reporters.solr.SolrClusterReporter" attribute. New Features ---------------------- @@ -141,6 +145,8 @@ Other Changes * SOLR-11071: Improve TestIntervalFacets.testRandom (Tomás Fernández Löbbe) +* SOLR-11195: Require class attribute for shard and cluster metric reporter configuration. (Christine Poerschke) + ================== 7.0.0 ================== Versions of Major Components diff --git a/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java b/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java index 8b17c78fe0b..001717c3844 100644 --- a/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java +++ b/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java @@ -1003,7 +1003,7 @@ public class SolrMetricManager { } } - private List prepareCloudPlugins(PluginInfo[] pluginInfos, String group, String className, + private List prepareCloudPlugins(PluginInfo[] pluginInfos, String group, Map defaultAttributes, Map defaultInitArgs) { List result = new ArrayList<>(); @@ -1015,7 +1015,7 @@ public class SolrMetricManager { if (!group.equals(groupAttr)) { continue; } - info = preparePlugin(info, className, defaultAttributes, defaultInitArgs); + info = preparePlugin(info, defaultAttributes, defaultInitArgs); if (info != null) { result.add(info); } @@ -1023,18 +1023,12 @@ public class SolrMetricManager { return result; } - private PluginInfo preparePlugin(PluginInfo info, String className, Map defaultAttributes, + private PluginInfo preparePlugin(PluginInfo info, Map defaultAttributes, Map defaultInitArgs) { if (info == null) { return null; } String classNameAttr = info.attributes.get("class"); - if (className != null) { - if (classNameAttr != null && !className.equals(classNameAttr)) { - log.warn("Conflicting class name attributes, expected " + className + " but was " + classNameAttr + ", skipping " + info); - return null; - } - } Map attrs = new HashMap<>(info.attributes); defaultAttributes.forEach((k, v) -> { @@ -1042,7 +1036,7 @@ public class SolrMetricManager { attrs.put(k, v); } }); - attrs.put("class", className); + attrs.put("class", classNameAttr); Map initArgs = new HashMap<>(); if (info.initArgs != null) { initArgs.putAll(info.initArgs.asMap(10)); @@ -1069,7 +1063,7 @@ public class SolrMetricManager { String registryName = core.getCoreMetricManager().getRegistryName(); // collect infos and normalize - List infos = prepareCloudPlugins(pluginInfos, SolrInfoBean.Group.shard.toString(), SolrShardReporter.class.getName(), + List infos = prepareCloudPlugins(pluginInfos, SolrInfoBean.Group.shard.toString(), attrs, initArgs); for (PluginInfo info : infos) { try { @@ -1092,7 +1086,7 @@ public class SolrMetricManager { attrs.put("group", SolrInfoBean.Group.cluster.toString()); Map initArgs = new HashMap<>(); initArgs.put("period", DEFAULT_CLOUD_REPORTER_PERIOD); - List infos = prepareCloudPlugins(pluginInfos, SolrInfoBean.Group.cluster.toString(), SolrClusterReporter.class.getName(), + List infos = prepareCloudPlugins(pluginInfos, SolrInfoBean.Group.cluster.toString(), attrs, initArgs); String registryName = getRegistryName(SolrInfoBean.Group.cluster); for (PluginInfo info : infos) { diff --git a/solr/core/src/test-files/solr/solr-solrreporter.xml b/solr/core/src/test-files/solr/solr-solrreporter.xml index a66d9d096e1..21f8ac1833c 100644 --- a/solr/core/src/test-files/solr/solr-solrreporter.xml +++ b/solr/core/src/test-files/solr/solr-solrreporter.xml @@ -42,12 +42,12 @@ false - + 5 UPDATE\./update/.*requests QUERY\./select.*requests - + /admin/metrics/collector 5