mirror of https://github.com/apache/lucene.git
SOLR-11389: For Solr(Shard|Cluster)Reporter instances the SolrMetricManager.registerReporter method is now called after the SolrCore or CoreContainer has been set for the instance.
This commit is contained in:
parent
227b441bde
commit
0b0ed21182
|
@ -73,6 +73,10 @@ Other Changes
|
|||
|
||||
* SOLR-11145: Adds comprehensive unit tests for the Analytics Component v2 (Houston Putman)
|
||||
|
||||
* SOLR-11389: For Solr(Shard|Cluster)Reporter instances the SolrMetricManager.registerReporter
|
||||
method is now called after the SolrCore or CoreContainer has been set for the instance.
|
||||
(Christine Poerschke)
|
||||
|
||||
================== 7.1.0 ==================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
|
||||
|
|
|
@ -549,9 +549,9 @@ public class CoreContainer {
|
|||
containerHandlers.put(PKIAuthenticationPlugin.PATH, pkiAuthenticationPlugin.getRequestHandler());
|
||||
|
||||
PluginInfo[] metricReporters = cfg.getMetricsConfig().getMetricReporters();
|
||||
metricManager.loadReporters(metricReporters, loader, null, SolrInfoBean.Group.node);
|
||||
metricManager.loadReporters(metricReporters, loader, null, SolrInfoBean.Group.jvm);
|
||||
metricManager.loadReporters(metricReporters, loader, null, SolrInfoBean.Group.jetty);
|
||||
metricManager.loadReporters(metricReporters, loader, this, null, null, SolrInfoBean.Group.node);
|
||||
metricManager.loadReporters(metricReporters, loader, this, null, null, SolrInfoBean.Group.jvm);
|
||||
metricManager.loadReporters(metricReporters, loader, this, null, null, SolrInfoBean.Group.jetty);
|
||||
|
||||
coreConfigService = ConfigSetService.createConfigSetService(cfg, loader, zkSys.zkController);
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.lang.invoke.MethodHandles;
|
|||
import com.codahale.metrics.MetricRegistry;
|
||||
import org.apache.solr.cloud.CloudDescriptor;
|
||||
import org.apache.solr.common.util.Utils;
|
||||
import org.apache.solr.core.CoreContainer;
|
||||
import org.apache.solr.core.NodeConfig;
|
||||
import org.apache.solr.core.PluginInfo;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
|
@ -82,9 +83,10 @@ public class SolrCoreMetricManager implements Closeable {
|
|||
* group or with a registry name specific to this core.
|
||||
*/
|
||||
public void loadReporters() {
|
||||
NodeConfig nodeConfig = core.getCoreContainer().getConfig();
|
||||
CoreContainer coreContainer = core.getCoreContainer();
|
||||
NodeConfig nodeConfig = coreContainer.getConfig();
|
||||
PluginInfo[] pluginInfos = nodeConfig.getMetricsConfig().getMetricReporters();
|
||||
metricManager.loadReporters(pluginInfos, core.getResourceLoader(), tag,
|
||||
metricManager.loadReporters(pluginInfos, core.getResourceLoader(), coreContainer, core, tag,
|
||||
SolrInfoBean.Group.core, registryName);
|
||||
if (cloudMode) {
|
||||
metricManager.loadShardReporters(pluginInfos, core);
|
||||
|
|
|
@ -769,12 +769,14 @@ public class SolrMetricManager {
|
|||
* the list. If both attributes are present then only "group" attribute will be processed.
|
||||
* @param pluginInfos plugin configurations
|
||||
* @param loader resource loader
|
||||
* @param coreContainer core container
|
||||
* @param solrCore optional solr core
|
||||
* @param tag optional tag for the reporters, to distinguish reporters logically created for different parent
|
||||
* component instances.
|
||||
* @param group selected group, not null
|
||||
* @param registryNames optional child registry name elements
|
||||
*/
|
||||
public void loadReporters(PluginInfo[] pluginInfos, SolrResourceLoader loader, String tag, SolrInfoBean.Group group, String... registryNames) {
|
||||
public void loadReporters(PluginInfo[] pluginInfos, SolrResourceLoader loader, CoreContainer coreContainer, SolrCore solrCore, String tag, SolrInfoBean.Group group, String... registryNames) {
|
||||
if (pluginInfos == null || pluginInfos.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -814,24 +816,51 @@ public class SolrMetricManager {
|
|||
}
|
||||
}
|
||||
try {
|
||||
loadReporter(registryName, loader, info, tag);
|
||||
loadReporter(registryName, loader, coreContainer, solrCore, info, tag);
|
||||
} catch (Exception e) {
|
||||
log.warn("Error loading metrics reporter, plugin info: " + info, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience wrapper for {@link SolrMetricManager#loadReporter(String, SolrResourceLoader, CoreContainer, SolrCore, PluginInfo, String)}
|
||||
* passing {@link SolrCore#getResourceLoader()} and {@link SolrCore#getCoreContainer()} as the extra parameters.
|
||||
*/
|
||||
public void loadReporter(String registry, SolrCore solrCore, PluginInfo pluginInfo, String tag) throws Exception {
|
||||
loadReporter(registry,
|
||||
solrCore.getResourceLoader(),
|
||||
solrCore.getCoreContainer(),
|
||||
solrCore,
|
||||
pluginInfo,
|
||||
tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience wrapper for {@link SolrMetricManager#loadReporter(String, SolrResourceLoader, CoreContainer, SolrCore, PluginInfo, String)}
|
||||
* passing {@link CoreContainer#getResourceLoader()} and null solrCore and tag.
|
||||
*/
|
||||
public void loadReporter(String registry, CoreContainer coreContainer, PluginInfo pluginInfo) throws Exception {
|
||||
loadReporter(registry,
|
||||
coreContainer.getResourceLoader(),
|
||||
coreContainer,
|
||||
null,
|
||||
pluginInfo,
|
||||
null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and register an instance of {@link SolrMetricReporter}.
|
||||
* @param registry reporter is associated with this registry
|
||||
* @param loader loader to use when creating an instance of the reporter
|
||||
* @param coreContainer core container
|
||||
* @param solrCore optional solr core
|
||||
* @param pluginInfo plugin configuration. Plugin "name" and "class" attributes are required.
|
||||
* @param tag optional tag for the reporter, to distinguish reporters logically created for different parent
|
||||
* component instances.
|
||||
* @return instance of newly created and registered reporter
|
||||
* @throws Exception if any argument is missing or invalid
|
||||
*/
|
||||
public SolrMetricReporter loadReporter(String registry, SolrResourceLoader loader, PluginInfo pluginInfo, String tag) throws Exception {
|
||||
public void loadReporter(String registry, SolrResourceLoader loader, CoreContainer coreContainer, SolrCore solrCore, PluginInfo pluginInfo, String tag) throws Exception {
|
||||
if (registry == null || pluginInfo == null || pluginInfo.name == null || pluginInfo.className == null) {
|
||||
throw new IllegalArgumentException("loadReporter called with missing arguments: " +
|
||||
"registry=" + registry + ", loader=" + loader + ", pluginInfo=" + pluginInfo);
|
||||
|
@ -846,12 +875,17 @@ public class SolrMetricManager {
|
|||
new Object[]{this, registry}
|
||||
);
|
||||
try {
|
||||
reporter.init(pluginInfo);
|
||||
if (reporter instanceof SolrShardReporter) {
|
||||
((SolrShardReporter)reporter).init(pluginInfo, solrCore);
|
||||
} else if (reporter instanceof SolrClusterReporter) {
|
||||
((SolrClusterReporter)reporter).init(pluginInfo, coreContainer);
|
||||
} else {
|
||||
reporter.init(pluginInfo);
|
||||
}
|
||||
} catch (IllegalStateException e) {
|
||||
throw new IllegalArgumentException("reporter init failed: " + pluginInfo, e);
|
||||
}
|
||||
registerReporter(registry, pluginInfo.name, tag, reporter);
|
||||
return reporter;
|
||||
}
|
||||
|
||||
private void registerReporter(String registry, String name, String tag, SolrMetricReporter reporter) throws Exception {
|
||||
|
@ -1078,9 +1112,8 @@ public class SolrMetricManager {
|
|||
attrs, initArgs);
|
||||
for (PluginInfo info : infos) {
|
||||
try {
|
||||
SolrMetricReporter reporter = loadReporter(registryName, core.getResourceLoader(), info,
|
||||
loadReporter(registryName, core, info,
|
||||
String.valueOf(core.hashCode()));
|
||||
((SolrShardReporter)reporter).setCore(core);
|
||||
} catch (Exception e) {
|
||||
log.warn("Could not load shard reporter, pluginInfo=" + info, e);
|
||||
}
|
||||
|
@ -1102,8 +1135,7 @@ public class SolrMetricManager {
|
|||
String registryName = getRegistryName(SolrInfoBean.Group.cluster);
|
||||
for (PluginInfo info : infos) {
|
||||
try {
|
||||
SolrMetricReporter reporter = loadReporter(registryName, cc.getResourceLoader(), info, null);
|
||||
((SolrClusterReporter)reporter).setCoreContainer(cc);
|
||||
loadReporter(registryName, cc, info);
|
||||
} catch (Exception e) {
|
||||
log.warn("Could not load cluster reporter, pluginInfo=" + info, e);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.solr.cloud.ZkController;
|
|||
import org.apache.solr.common.cloud.SolrZkClient;
|
||||
import org.apache.solr.common.cloud.ZkNodeProps;
|
||||
import org.apache.solr.core.CoreContainer;
|
||||
import org.apache.solr.core.PluginInfo;
|
||||
import org.apache.solr.core.SolrInfoBean;
|
||||
import org.apache.solr.handler.admin.MetricsCollectorHandler;
|
||||
import org.apache.solr.metrics.SolrMetricManager;
|
||||
|
@ -168,6 +169,11 @@ public class SolrClusterReporter extends SolrMetricReporter {
|
|||
return reports;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(PluginInfo pluginInfo) {
|
||||
throw new UnsupportedOperationException(getClass().getCanonicalName()+".init(PluginInfo) is not supported, use init(PluginInfo,CoreContainer) instead.");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInit() {
|
||||
if (reports.isEmpty()) { // set defaults
|
||||
|
@ -187,7 +193,8 @@ public class SolrClusterReporter extends SolrMetricReporter {
|
|||
}
|
||||
}
|
||||
|
||||
public void setCoreContainer(CoreContainer cc) {
|
||||
public void init(PluginInfo pluginInfo, CoreContainer cc) {
|
||||
super.init(pluginInfo);
|
||||
if (reporter != null) {
|
||||
reporter.close();;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.solr.cloud.CloudDescriptor;
|
|||
import org.apache.solr.common.cloud.ClusterState;
|
||||
import org.apache.solr.common.cloud.DocCollection;
|
||||
import org.apache.solr.common.cloud.Replica;
|
||||
import org.apache.solr.core.PluginInfo;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.handler.admin.MetricsCollectorHandler;
|
||||
import org.apache.solr.metrics.FilteringSolrMetricReporter;
|
||||
|
@ -90,6 +91,11 @@ public class SolrShardReporter extends FilteringSolrMetricReporter {
|
|||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(PluginInfo pluginInfo) {
|
||||
throw new UnsupportedOperationException(getClass().getCanonicalName()+".init(PluginInfo) is not supported, use init(PluginInfo,SolrCore) instead.");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInit() {
|
||||
if (filters.isEmpty()) {
|
||||
|
@ -116,7 +122,8 @@ public class SolrShardReporter extends FilteringSolrMetricReporter {
|
|||
}
|
||||
}
|
||||
|
||||
public void setCore(SolrCore core) {
|
||||
public void init(PluginInfo pluginInfo, SolrCore core) {
|
||||
super.init(pluginInfo);
|
||||
if (reporter != null) {
|
||||
reporter.close();
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ public class SolrCoreMetricManagerTest extends SolrTestCaseJ4 {
|
|||
PluginInfo pluginInfo = shouldDefinePlugin ? new PluginInfo(TestUtil.randomUnicodeString(random), attrs) : null;
|
||||
|
||||
try {
|
||||
metricManager.loadReporter(coreMetricManager.getRegistryName(), coreMetricManager.getCore().getResourceLoader(),
|
||||
metricManager.loadReporter(coreMetricManager.getRegistryName(), coreMetricManager.getCore(),
|
||||
pluginInfo, String.valueOf(coreMetricManager.getCore().hashCode()));
|
||||
assertNotNull(pluginInfo);
|
||||
Map<String, SolrMetricReporter> reporters = metricManager.getReporters(coreMetricManager.getRegistryName());
|
||||
|
|
|
@ -205,7 +205,7 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
|
|||
createPluginInfo("core_foo", "core", null)
|
||||
};
|
||||
String tag = "xyz";
|
||||
metricManager.loadReporters(plugins, loader, tag, SolrInfoBean.Group.node);
|
||||
metricManager.loadReporters(plugins, loader, null, null, tag, SolrInfoBean.Group.node);
|
||||
Map<String, SolrMetricReporter> reporters = metricManager.getReporters(
|
||||
SolrMetricManager.getRegistryName(SolrInfoBean.Group.node));
|
||||
assertEquals(4, reporters.size());
|
||||
|
@ -214,7 +214,7 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
|
|||
assertTrue(reporters.containsKey("node_foo@" + tag));
|
||||
assertTrue(reporters.containsKey("multiregistry_foo@" + tag));
|
||||
|
||||
metricManager.loadReporters(plugins, loader, tag, SolrInfoBean.Group.core, "collection1");
|
||||
metricManager.loadReporters(plugins, loader, null, null, tag, SolrInfoBean.Group.core, "collection1");
|
||||
reporters = metricManager.getReporters(
|
||||
SolrMetricManager.getRegistryName(SolrInfoBean.Group.core, "collection1"));
|
||||
assertEquals(5, reporters.size());
|
||||
|
@ -224,7 +224,7 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
|
|||
assertTrue(reporters.containsKey("core_foo@" + tag));
|
||||
assertTrue(reporters.containsKey("multiregistry_foo@" + tag));
|
||||
|
||||
metricManager.loadReporters(plugins, loader, tag, SolrInfoBean.Group.jvm);
|
||||
metricManager.loadReporters(plugins, loader, null, null, tag, SolrInfoBean.Group.jvm);
|
||||
reporters = metricManager.getReporters(
|
||||
SolrMetricManager.getRegistryName(SolrInfoBean.Group.jvm));
|
||||
assertEquals(2, reporters.size());
|
||||
|
|
|
@ -80,7 +80,7 @@ public class SolrJmxReporterTest extends SolrTestCaseJ4 {
|
|||
coreMetricManager = core.getCoreMetricManager();
|
||||
metricManager = core.getCoreContainer().getMetricManager();
|
||||
PluginInfo pluginInfo = createReporterPluginInfo(rootName, true);
|
||||
metricManager.loadReporter(coreMetricManager.getRegistryName(), coreMetricManager.getCore().getResourceLoader(),
|
||||
metricManager.loadReporter(coreMetricManager.getRegistryName(), coreMetricManager.getCore(),
|
||||
pluginInfo, coreMetricManager.getTag());
|
||||
|
||||
Map<String, SolrMetricReporter> reporters = metricManager.getReporters(coreMetricManager.getRegistryName());
|
||||
|
@ -165,7 +165,7 @@ public class SolrJmxReporterTest extends SolrTestCaseJ4 {
|
|||
|
||||
h.getCoreContainer().reload(h.getCore().getName());
|
||||
PluginInfo pluginInfo = createReporterPluginInfo(rootName, true);
|
||||
metricManager.loadReporter(coreMetricManager.getRegistryName(), coreMetricManager.getCore().getResourceLoader(),
|
||||
metricManager.loadReporter(coreMetricManager.getRegistryName(), coreMetricManager.getCore(),
|
||||
pluginInfo, String.valueOf(coreMetricManager.getCore().hashCode()));
|
||||
coreMetricManager.registerMetricProducer(scope, producer);
|
||||
|
||||
|
@ -214,13 +214,13 @@ public class SolrJmxReporterTest extends SolrTestCaseJ4 {
|
|||
public void testEnabled() throws Exception {
|
||||
String root1 = PREFIX + TestUtil.randomSimpleString(random(), 5, 10);
|
||||
PluginInfo pluginInfo1 = createReporterPluginInfo(root1, true);
|
||||
metricManager.loadReporter(coreMetricManager.getRegistryName(), coreMetricManager.getCore().getResourceLoader(),
|
||||
metricManager.loadReporter(coreMetricManager.getRegistryName(), coreMetricManager.getCore(),
|
||||
pluginInfo1, coreMetricManager.getTag());
|
||||
|
||||
String root2 = PREFIX + TestUtil.randomSimpleString(random(), 5, 10);
|
||||
assertFalse(root2.equals(root1));
|
||||
PluginInfo pluginInfo2 = createReporterPluginInfo(root2, false);
|
||||
metricManager.loadReporter(coreMetricManager.getRegistryName(), coreMetricManager.getCore().getResourceLoader(),
|
||||
metricManager.loadReporter(coreMetricManager.getRegistryName(), coreMetricManager.getCore(),
|
||||
pluginInfo2, coreMetricManager.getTag());
|
||||
|
||||
Map<String, SolrMetricReporter> reporters = metricManager.getReporters(coreMetricManager.getRegistryName());
|
||||
|
|
Loading…
Reference in New Issue