mirror of https://github.com/apache/lucene.git
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/lucene-solr
This commit is contained in:
commit
e2474be5ea
|
@ -80,7 +80,7 @@
|
|||
<!-- Needed in case a module needs the original build, also for compile-tools to be called from a module -->
|
||||
<property name="common.build.dir" location="${common.dir}/build"/>
|
||||
|
||||
<property name="ivy.bootstrap.version" value="2.3.0" />
|
||||
<property name="ivy.bootstrap.version" value="2.3.0" /> <!-- UPGRADE NOTE: update disallowed.ivy.jars regex in ivy-availability-check -->
|
||||
<property name="ivy.default.configuration" value="*"/>
|
||||
|
||||
<!-- Running ant targets in parralel may require this set to false because ivy:retrieve tasks may race with resolve -->
|
||||
|
@ -416,12 +416,35 @@
|
|||
<property name="ivy_checksum_sha1" value="c5ebf1c253ad4959a29f4acfe696ee48cdd9f473"/>
|
||||
|
||||
<target name="ivy-availability-check" unless="ivy.available">
|
||||
<path id="disallowed.ivy.jars">
|
||||
<fileset dir="${ivy_install_path}">
|
||||
<filename regex="ivy-2\.[012].*\.jar"/> <!-- TODO: Update this regex to disallow Ivy versions -->
|
||||
</fileset>
|
||||
</path>
|
||||
<loadresource property="disallowed.ivy.jars.list">
|
||||
<string value="${toString:disallowed.ivy.jars}"/>
|
||||
<filterchain><tokenfilter><replacestring from="jar:" to="jar, "/></tokenfilter></filterchain>
|
||||
</loadresource>
|
||||
<condition property="disallowed.ivy.jar.found">
|
||||
<resourcecount when="greater" count="0">
|
||||
<path refid="disallowed.ivy.jars"/>
|
||||
</resourcecount>
|
||||
</condition>
|
||||
<antcall target="-ivy-fail-disallowed-ivy-version"/>
|
||||
|
||||
<condition property="ivy.available">
|
||||
<typefound uri="antlib:org.apache.ivy.ant" name="configure" />
|
||||
</condition>
|
||||
<antcall target="ivy-fail" />
|
||||
</target>
|
||||
|
||||
<target name="-ivy-fail-disallowed-ivy-version" if="disallowed.ivy.jar.found">
|
||||
<sequential>
|
||||
<echo message="Please delete the following disallowed Ivy jar(s): ${disallowed.ivy.jars.list}"/>
|
||||
<fail>Found disallowed Ivy jar(s): ${disallowed.ivy.jars.list}</fail>
|
||||
</sequential>
|
||||
</target>
|
||||
|
||||
<target name="ivy-fail" unless="ivy.available">
|
||||
<echo>
|
||||
This build requires Ivy and Ivy could not be found in your ant classpath.
|
||||
|
|
|
@ -57,7 +57,6 @@ public class SolrSlf4jReporter extends FilteringSolrMetricReporter {
|
|||
private String logger = null;
|
||||
private Slf4jReporter reporter;
|
||||
private boolean active;
|
||||
private DiagnosticMetricRegistry diagnosticMetricRegistry;
|
||||
|
||||
/**
|
||||
* Create a SLF4J reporter for metrics managed in a named registry.
|
||||
|
@ -85,10 +84,8 @@ public class SolrSlf4jReporter extends FilteringSolrMetricReporter {
|
|||
} else {
|
||||
instancePrefix = instancePrefix + "." + registryName;
|
||||
}
|
||||
MetricRegistry registry = metricManager.registry(registryName);
|
||||
diagnosticMetricRegistry = new DiagnosticMetricRegistry(registry);
|
||||
Slf4jReporter.Builder builder = Slf4jReporter
|
||||
.forRegistry(diagnosticMetricRegistry)
|
||||
.forRegistry(metricManager.registry(registryName))
|
||||
.convertRatesTo(TimeUnit.SECONDS)
|
||||
.convertDurationsTo(TimeUnit.MILLISECONDS);
|
||||
|
||||
|
@ -133,43 +130,4 @@ public class SolrSlf4jReporter extends FilteringSolrMetricReporter {
|
|||
boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
// for unit tests
|
||||
int getCount() {
|
||||
return diagnosticMetricRegistry != null ? diagnosticMetricRegistry.count : -1;
|
||||
}
|
||||
|
||||
static class DiagnosticMetricRegistry extends MetricRegistry {
|
||||
MetricRegistry delegate;
|
||||
int count = 0;
|
||||
DiagnosticMetricRegistry(MetricRegistry delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<String, Counter> getCounters(MetricFilter filter) {
|
||||
return delegate.getCounters(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<String, Histogram> getHistograms(MetricFilter filter) {
|
||||
return delegate.getHistograms(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<String, Meter> getMeters(MetricFilter filter) {
|
||||
return delegate.getMeters(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<String, Timer> getTimers(MetricFilter filter) {
|
||||
return delegate.getTimers(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<String, Gauge> getGauges(MetricFilter filter) {
|
||||
count++;
|
||||
return delegate.getGauges(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ import java.util.Properties;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.LuceneTestCase.AwaitsFix;
|
||||
import org.apache.lucene.util.LuceneTestCase.Slow;
|
||||
import org.apache.solr.JSONTestUtil;
|
||||
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
|
||||
|
@ -65,6 +67,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
@Slow
|
||||
@SuppressSSL(bugUrl = "https://issues.apache.org/jira/browse/SOLR-5776")
|
||||
@AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-11293")
|
||||
public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.apache.solr.metrics.reporters;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Map;
|
||||
|
@ -34,14 +35,18 @@ import org.apache.solr.metrics.SolrMetricManager;
|
|||
import org.apache.solr.metrics.SolrMetricReporter;
|
||||
import org.apache.solr.util.TestHarness;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class SolrSlf4jReporterTest extends SolrTestCaseJ4 {
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
@Test
|
||||
public void testReporter() throws Exception {
|
||||
ensureLoggingConfiguredAppropriately();
|
||||
LogWatcherConfig watcherCfg = new LogWatcherConfig(true, null, null, 100);
|
||||
LogWatcher watcher = LogWatcher.newRegisteredLogWatcher(watcherCfg, null);
|
||||
watcher.setThreshold("INFO");
|
||||
|
@ -78,19 +83,20 @@ public class SolrSlf4jReporterTest extends SolrTestCaseJ4 {
|
|||
}
|
||||
Thread.sleep(5000);
|
||||
|
||||
int count1 = ((SolrSlf4jReporter)reporter1).getCount();
|
||||
assertTrue("test1 count should be greater than 0", count1 > 0);
|
||||
int count2 = ((SolrSlf4jReporter)reporter2).getCount();
|
||||
assertTrue("test2 count should be greater than 0", count1 > 0);
|
||||
|
||||
SolrDocumentList history = watcher.getHistory(-1, null);
|
||||
// dot-separated names are treated like class names and collapsed
|
||||
// in regular log output, but here we get the full name
|
||||
if (history.stream().filter(d -> "solr.node".equals(d.getFirstValue("logger"))).count() == 0) {
|
||||
fail("count1=" + count1 + ", count2=" + count2 + " - no 'solr.node' logs in: " + history.toString());
|
||||
fail("No 'solr.node' logs in: " + history.toString());
|
||||
}
|
||||
if (history.stream().filter(d -> "foobar".equals(d.getFirstValue("logger"))).count() == 0) {
|
||||
fail("count1=" + count1 + ", count2=" + count2 + " - no 'foobar' logs in: " + history.toString());
|
||||
fail("No 'foobar' logs in: " + history.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static void ensureLoggingConfiguredAppropriately() throws Exception {
|
||||
if (! log.isInfoEnabled()) {
|
||||
fail("Test requires that log-level is at-least INFO, but INFO is disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue