mirror of
https://github.com/apache/lucene.git
synced 2025-02-24 11:16:35 +00:00
SOLR-11291: Factor out abstract metrics/SolrCore[Container]Reporter classes. (Omar Abdelnabi, Christine Poerschke)
This commit is contained in:
parent
64b3a5bb4b
commit
812db14f27
@ -211,6 +211,9 @@ Other Changes
|
||||
* SOLR-11507: SOLR-11638: Randomize SolrTestCaseJ4.CloudSolrClientBuilder more, and simplify it.
|
||||
(Jason Gerlowski, David Smiley)
|
||||
|
||||
* SOLR-11291: Factor out abstract metrics/SolrCore[Container]Reporter classes.
|
||||
(Omar Abdelnabi, Christine Poerschke)
|
||||
|
||||
================== 7.1.0 ==================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
|
||||
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.solr.metrics;
|
||||
|
||||
import org.apache.solr.core.CoreContainer;
|
||||
import org.apache.solr.core.PluginInfo;
|
||||
|
||||
/**
|
||||
* A {@link SolrMetricReporter} that has access to its {@link CoreContainer}.
|
||||
*/
|
||||
abstract public class SolrCoreContainerReporter extends SolrMetricReporter {
|
||||
|
||||
protected CoreContainer coreContainer;
|
||||
|
||||
protected SolrCoreContainerReporter(SolrMetricManager metricManager, String registryName) {
|
||||
super(metricManager, registryName);
|
||||
}
|
||||
|
||||
@Override
|
||||
final public void init(PluginInfo pluginInfo) {
|
||||
throw new UnsupportedOperationException(getClass().getCanonicalName()+".init(PluginInfo) is not supported, use init(PluginInfo,CoreContainer) instead.");
|
||||
}
|
||||
|
||||
public void init(PluginInfo pluginInfo, CoreContainer coreContainer) {
|
||||
super.init(pluginInfo);
|
||||
this.coreContainer = coreContainer;
|
||||
}
|
||||
|
||||
public CoreContainer getCoreContainer() {
|
||||
return coreContainer;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.solr.metrics;
|
||||
|
||||
import org.apache.solr.core.PluginInfo;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
|
||||
/**
|
||||
* A {@link FilteringSolrMetricReporter} that has access to its {@link SolrCore}.
|
||||
*/
|
||||
abstract public class SolrCoreReporter extends FilteringSolrMetricReporter {
|
||||
|
||||
protected SolrCore core;
|
||||
|
||||
public SolrCoreReporter(SolrMetricManager metricManager, String registryName) {
|
||||
super(metricManager, registryName);
|
||||
}
|
||||
|
||||
@Override
|
||||
final public void init(PluginInfo pluginInfo) {
|
||||
throw new UnsupportedOperationException(getClass().getCanonicalName()+".init(PluginInfo) is not supported, use init(PluginInfo,SolrCore) instead.");
|
||||
}
|
||||
|
||||
public void init(PluginInfo pluginInfo, SolrCore core) {
|
||||
super.init(pluginInfo);
|
||||
this.core = core;
|
||||
}
|
||||
|
||||
public SolrCore getCore() {
|
||||
return core;
|
||||
}
|
||||
|
||||
}
|
@ -54,8 +54,6 @@ import org.apache.solr.core.PluginInfo;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.core.SolrInfoBean;
|
||||
import org.apache.solr.core.SolrResourceLoader;
|
||||
import org.apache.solr.metrics.reporters.solr.SolrClusterReporter;
|
||||
import org.apache.solr.metrics.reporters.solr.SolrShardReporter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -875,10 +873,10 @@ public class SolrMetricManager {
|
||||
new Object[]{this, registry}
|
||||
);
|
||||
try {
|
||||
if (reporter instanceof SolrShardReporter) {
|
||||
((SolrShardReporter)reporter).init(pluginInfo, solrCore);
|
||||
} else if (reporter instanceof SolrClusterReporter) {
|
||||
((SolrClusterReporter)reporter).init(pluginInfo, coreContainer);
|
||||
if (reporter instanceof SolrCoreReporter) {
|
||||
((SolrCoreReporter)reporter).init(pluginInfo, solrCore);
|
||||
} else if (reporter instanceof SolrCoreContainerReporter) {
|
||||
((SolrCoreContainerReporter)reporter).init(pluginInfo, coreContainer);
|
||||
} else {
|
||||
reporter.init(pluginInfo);
|
||||
}
|
||||
|
@ -36,8 +36,8 @@ 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.SolrCoreContainerReporter;
|
||||
import org.apache.solr.metrics.SolrMetricManager;
|
||||
import org.apache.solr.metrics.SolrMetricReporter;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -90,7 +90,7 @@ import static org.apache.solr.common.params.CommonParams.ID;
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
public class SolrClusterReporter extends SolrMetricReporter {
|
||||
public class SolrClusterReporter extends SolrCoreContainerReporter {
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
public static final String CLUSTER_GROUP = SolrMetricManager.overridableRegistryName(SolrInfoBean.Group.cluster.toString());
|
||||
@ -169,11 +169,6 @@ 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
|
||||
@ -193,8 +188,9 @@ public class SolrClusterReporter extends SolrMetricReporter {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(PluginInfo pluginInfo, CoreContainer cc) {
|
||||
super.init(pluginInfo);
|
||||
super.init(pluginInfo, cc);
|
||||
if (reporter != null) {
|
||||
reporter.close();;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ 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;
|
||||
import org.apache.solr.metrics.SolrCoreReporter;
|
||||
import org.apache.solr.metrics.SolrMetricManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -59,7 +59,7 @@ import com.codahale.metrics.MetricFilter;
|
||||
* </reporter>
|
||||
* </pre>
|
||||
*/
|
||||
public class SolrShardReporter extends FilteringSolrMetricReporter {
|
||||
public class SolrShardReporter extends SolrCoreReporter {
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
public static final List<String> DEFAULT_FILTERS = new ArrayList(){{
|
||||
@ -91,11 +91,6 @@ 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()) {
|
||||
@ -122,8 +117,9 @@ public class SolrShardReporter extends FilteringSolrMetricReporter {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(PluginInfo pluginInfo, SolrCore core) {
|
||||
super.init(pluginInfo);
|
||||
super.init(pluginInfo, core);
|
||||
if (reporter != null) {
|
||||
reporter.close();
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ import org.apache.solr.cloud.SolrCloudTestCase;
|
||||
import org.apache.solr.core.CoreContainer;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.metrics.AggregateMetric;
|
||||
import org.apache.solr.metrics.SolrCoreContainerReporter;
|
||||
import org.apache.solr.metrics.SolrCoreReporter;
|
||||
import org.apache.solr.metrics.SolrMetricManager;
|
||||
import org.apache.solr.metrics.SolrMetricReporter;
|
||||
import org.apache.solr.metrics.reporters.SolrJmxReporter;
|
||||
@ -96,6 +98,9 @@ public class SolrCloudReportersTest extends SolrCloudTestCase {
|
||||
assertNotNull(reporter);
|
||||
assertTrue(reporter.toString(), reporter instanceof SolrClusterReporter);
|
||||
assertEquals(5, reporter.getPeriod());
|
||||
assertTrue(reporter.toString(), reporter instanceof SolrCoreContainerReporter);
|
||||
SolrCoreContainerReporter solrCoreContainerReporter = (SolrCoreContainerReporter)reporter;
|
||||
assertNotNull(solrCoreContainerReporter.getCoreContainer());
|
||||
for (String registryName : metricManager.registryNames(".*\\.shard[0-9]\\.replica.*")) {
|
||||
reporters = metricManager.getReporters(registryName);
|
||||
jmxReporter = 0;
|
||||
@ -114,6 +119,9 @@ public class SolrCloudReportersTest extends SolrCloudTestCase {
|
||||
assertNotNull(reporter);
|
||||
assertTrue(reporter.toString(), reporter instanceof SolrShardReporter);
|
||||
assertEquals(5, reporter.getPeriod());
|
||||
assertTrue(reporter.toString(), reporter instanceof SolrCoreReporter);
|
||||
SolrCoreReporter solrCoreReporter = (SolrCoreReporter)reporter;
|
||||
assertNotNull(solrCoreReporter.getCore());
|
||||
}
|
||||
for (String registryName : metricManager.registryNames(".*\\.leader")) {
|
||||
leaderRegistries++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user