SOLR-11195: Require class attribute for shard and cluster metric reporter configuration.

This commit is contained in:
Christine Poerschke 2017-08-11 12:34:52 +01:00
parent 6e9538c719
commit 3959c53eaf
3 changed files with 15 additions and 15 deletions

View File

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

View File

@ -1003,7 +1003,7 @@ public class SolrMetricManager {
}
}
private List<PluginInfo> prepareCloudPlugins(PluginInfo[] pluginInfos, String group, String className,
private List<PluginInfo> prepareCloudPlugins(PluginInfo[] pluginInfos, String group,
Map<String, String> defaultAttributes,
Map<String, Object> defaultInitArgs) {
List<PluginInfo> 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<String, String> defaultAttributes,
private PluginInfo preparePlugin(PluginInfo info, Map<String, String> defaultAttributes,
Map<String, Object> 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<String, String> 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<String, Object> 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<PluginInfo> infos = prepareCloudPlugins(pluginInfos, SolrInfoBean.Group.shard.toString(), SolrShardReporter.class.getName(),
List<PluginInfo> 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<String, Object> initArgs = new HashMap<>();
initArgs.put("period", DEFAULT_CLOUD_REPORTER_PERIOD);
List<PluginInfo> infos = prepareCloudPlugins(pluginInfos, SolrInfoBean.Group.cluster.toString(), SolrClusterReporter.class.getName(),
List<PluginInfo> infos = prepareCloudPlugins(pluginInfos, SolrInfoBean.Group.cluster.toString(),
attrs, initArgs);
String registryName = getRegistryName(SolrInfoBean.Group.cluster);
for (PluginInfo info : infos) {

View File

@ -42,12 +42,12 @@
<reporter name="defaultJmx" class="org.apache.solr.metrics.reporters.SolrJmxReporter">
<bool name="enabled">false</bool>
</reporter>
<reporter name="test" group="shard">
<reporter name="test" group="shard" class="org.apache.solr.metrics.reporters.solr.SolrShardReporter">
<int name="period">5</int>
<str name="filter">UPDATE\./update/.*requests</str>
<str name="filter">QUERY\./select.*requests</str>
</reporter>
<reporter name="test" group="cluster">
<reporter name="test" group="cluster" class="org.apache.solr.metrics.reporters.solr.SolrClusterReporter">
<str name="handler">/admin/metrics/collector</str>
<int name="period">5</int>
<lst name="report">