mirror of https://github.com/apache/lucene.git
SOLR-10823: Add reporting period to SolrMetricReporter base class.
This commit is contained in:
parent
7c448623cc
commit
44860bd48a
|
@ -517,6 +517,8 @@ Other Changes
|
|||
with point fields and provides control over dynamic fields used for the raw amount and currency
|
||||
code sub-fields. (hossman, Steve Rowe)
|
||||
|
||||
* SOLR-10823: Add reporting period to SolrMetricReporter base class. (Christine Poerschke)
|
||||
|
||||
================== 6.6.1 ==================
|
||||
|
||||
Bug Fixes
|
||||
|
|
|
@ -36,6 +36,7 @@ public abstract class SolrMetricReporter implements Closeable, PluginInfoInitial
|
|||
protected final SolrMetricManager metricManager;
|
||||
protected PluginInfo pluginInfo;
|
||||
protected boolean enabled = true;
|
||||
protected int period = SolrMetricManager.DEFAULT_CLOUD_REPORTER_PERIOD;
|
||||
|
||||
/**
|
||||
* Create a reporter for metrics managed in a named registry.
|
||||
|
@ -85,6 +86,20 @@ public abstract class SolrMetricReporter implements Closeable, PluginInfoInitial
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param period - in seconds
|
||||
*/
|
||||
public void setPeriod(int period) {
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return period, in seconds
|
||||
*/
|
||||
public int getPeriod() {
|
||||
return period;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the effective {@link PluginInfo} instance that was used for
|
||||
* initialization of this plugin.
|
||||
|
|
|
@ -35,7 +35,6 @@ public class SolrGangliaReporter extends SolrMetricReporter {
|
|||
private String host = null;
|
||||
private int port = -1;
|
||||
private boolean multicast;
|
||||
private int period = 60;
|
||||
private String instancePrefix = null;
|
||||
private List<String> filters = new ArrayList<>();
|
||||
private boolean testing;
|
||||
|
@ -88,10 +87,6 @@ public class SolrGangliaReporter extends SolrMetricReporter {
|
|||
}
|
||||
}
|
||||
|
||||
public void setPeriod(int period) {
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
public void setMulticast(boolean multicast) {
|
||||
this.multicast = multicast;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ public class SolrGraphiteReporter extends SolrMetricReporter {
|
|||
|
||||
private String host = null;
|
||||
private int port = -1;
|
||||
private int period = 60;
|
||||
private boolean pickled = false;
|
||||
private String instancePrefix = null;
|
||||
private List<String> filters = new ArrayList<>();
|
||||
|
@ -90,10 +89,6 @@ public class SolrGraphiteReporter extends SolrMetricReporter {
|
|||
this.pickled = pickled;
|
||||
}
|
||||
|
||||
public void setPeriod(int period) {
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInit() {
|
||||
if (reporter != null) {
|
||||
|
|
|
@ -70,6 +70,7 @@ public class SolrJmxReporter extends SolrMetricReporter {
|
|||
*/
|
||||
public SolrJmxReporter(SolrMetricManager metricManager, String registryName) {
|
||||
super(metricManager, registryName);
|
||||
period = 0; // setting to zero to indicate not applicable
|
||||
setDomain(registryName);
|
||||
}
|
||||
|
||||
|
@ -151,7 +152,9 @@ public class SolrJmxReporter extends SolrMetricReporter {
|
|||
*/
|
||||
@Override
|
||||
protected void validate() throws IllegalStateException {
|
||||
// Nothing to validate
|
||||
if (period != 0) {
|
||||
throw new IllegalStateException("Init argument 'period' is not supported for "+getClass().getCanonicalName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@ public class SolrSlf4jReporter extends SolrMetricReporter {
|
|||
@SuppressWarnings("unused") // we need this to pass validate-source-patterns
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
private int period = 60;
|
||||
private String instancePrefix = null;
|
||||
private String logger = null;
|
||||
private List<String> filters = new ArrayList<>();
|
||||
|
@ -91,10 +90,6 @@ public class SolrSlf4jReporter extends SolrMetricReporter {
|
|||
this.logger = logger;
|
||||
}
|
||||
|
||||
public void setPeriod(int period) {
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInit() {
|
||||
if (instancePrefix == null) {
|
||||
|
|
|
@ -124,7 +124,6 @@ public class SolrClusterReporter extends SolrMetricReporter {
|
|||
}};
|
||||
|
||||
private String handler = MetricsCollectorHandler.HANDLER_PATH;
|
||||
private int period = SolrMetricManager.DEFAULT_CLOUD_REPORTER_PERIOD;
|
||||
private List<SolrReporter.Report> reports = new ArrayList<>();
|
||||
|
||||
private SolrReporter reporter;
|
||||
|
@ -143,10 +142,6 @@ public class SolrClusterReporter extends SolrMetricReporter {
|
|||
this.handler = handler;
|
||||
}
|
||||
|
||||
public void setPeriod(int period) {
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
public void setReport(List<Map> reportConfig) {
|
||||
if (reportConfig == null || reportConfig.isEmpty()) {
|
||||
return;
|
||||
|
@ -169,11 +164,6 @@ public class SolrClusterReporter extends SolrMetricReporter {
|
|||
}
|
||||
}
|
||||
|
||||
// for unit tests
|
||||
int getPeriod() {
|
||||
return period;
|
||||
}
|
||||
|
||||
List<SolrReporter.Report> getReports() {
|
||||
return reports;
|
||||
}
|
||||
|
@ -187,7 +177,7 @@ public class SolrClusterReporter extends SolrMetricReporter {
|
|||
|
||||
@Override
|
||||
protected void validate() throws IllegalStateException {
|
||||
// Nothing to validate
|
||||
// (period < 1) means "don't start reporter" and so no (period > 0) validation needed
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -70,7 +70,6 @@ public class SolrShardReporter extends SolrMetricReporter {
|
|||
}};
|
||||
|
||||
private String handler = MetricsCollectorHandler.HANDLER_PATH;
|
||||
private int period = SolrMetricManager.DEFAULT_CLOUD_REPORTER_PERIOD;
|
||||
private List<String> filters = new ArrayList<>();
|
||||
|
||||
private SolrReporter reporter;
|
||||
|
@ -90,10 +89,6 @@ public class SolrShardReporter extends SolrMetricReporter {
|
|||
this.handler = handler;
|
||||
}
|
||||
|
||||
public void setPeriod(int period) {
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
public void setFilter(List<String> filterConfig) {
|
||||
if (filterConfig == null || filterConfig.isEmpty()) {
|
||||
return;
|
||||
|
@ -107,11 +102,6 @@ public class SolrShardReporter extends SolrMetricReporter {
|
|||
}
|
||||
}
|
||||
|
||||
// for unit tests
|
||||
int getPeriod() {
|
||||
return period;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInit() {
|
||||
if (filters.isEmpty()) {
|
||||
|
@ -122,7 +112,7 @@ public class SolrShardReporter extends SolrMetricReporter {
|
|||
|
||||
@Override
|
||||
protected void validate() throws IllegalStateException {
|
||||
// Nothing to validate
|
||||
// (period < 1) means "don't start reporter" and so no (period > 0) validation needed
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -249,6 +249,11 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultCloudReporterPeriodUnchanged() throws Exception {
|
||||
assertEquals(60, SolrMetricManager.DEFAULT_CLOUD_REPORTER_PERIOD);
|
||||
}
|
||||
|
||||
private PluginInfo createPluginInfo(String name, String group, String registry) {
|
||||
Map<String,String> attrs = new HashMap<>();
|
||||
attrs.put("name", name);
|
||||
|
|
|
@ -53,6 +53,9 @@ public class MockMetricReporter extends SolrMetricReporter {
|
|||
if (configurable == null) {
|
||||
throw new IllegalStateException("MockMetricReporter::configurable not defined.");
|
||||
}
|
||||
if (period < 1) {
|
||||
throw new IllegalStateException("Init argument 'period' is in time unit 'seconds' and must be at least 1.");
|
||||
}
|
||||
}
|
||||
|
||||
public void setConfigurable(String configurable) {
|
||||
|
|
Loading…
Reference in New Issue