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 -->
|
<!-- 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="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="*"/>
|
<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 -->
|
<!-- 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"/>
|
<property name="ivy_checksum_sha1" value="c5ebf1c253ad4959a29f4acfe696ee48cdd9f473"/>
|
||||||
|
|
||||||
<target name="ivy-availability-check" unless="ivy.available">
|
<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">
|
<condition property="ivy.available">
|
||||||
<typefound uri="antlib:org.apache.ivy.ant" name="configure" />
|
<typefound uri="antlib:org.apache.ivy.ant" name="configure" />
|
||||||
</condition>
|
</condition>
|
||||||
<antcall target="ivy-fail" />
|
<antcall target="ivy-fail" />
|
||||||
</target>
|
</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">
|
<target name="ivy-fail" unless="ivy.available">
|
||||||
<echo>
|
<echo>
|
||||||
This build requires Ivy and Ivy could not be found in your ant classpath.
|
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 String logger = null;
|
||||||
private Slf4jReporter reporter;
|
private Slf4jReporter reporter;
|
||||||
private boolean active;
|
private boolean active;
|
||||||
private DiagnosticMetricRegistry diagnosticMetricRegistry;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a SLF4J reporter for metrics managed in a named registry.
|
* Create a SLF4J reporter for metrics managed in a named registry.
|
||||||
|
@ -85,10 +84,8 @@ public class SolrSlf4jReporter extends FilteringSolrMetricReporter {
|
||||||
} else {
|
} else {
|
||||||
instancePrefix = instancePrefix + "." + registryName;
|
instancePrefix = instancePrefix + "." + registryName;
|
||||||
}
|
}
|
||||||
MetricRegistry registry = metricManager.registry(registryName);
|
|
||||||
diagnosticMetricRegistry = new DiagnosticMetricRegistry(registry);
|
|
||||||
Slf4jReporter.Builder builder = Slf4jReporter
|
Slf4jReporter.Builder builder = Slf4jReporter
|
||||||
.forRegistry(diagnosticMetricRegistry)
|
.forRegistry(metricManager.registry(registryName))
|
||||||
.convertRatesTo(TimeUnit.SECONDS)
|
.convertRatesTo(TimeUnit.SECONDS)
|
||||||
.convertDurationsTo(TimeUnit.MILLISECONDS);
|
.convertDurationsTo(TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
|
@ -133,43 +130,4 @@ public class SolrSlf4jReporter extends FilteringSolrMetricReporter {
|
||||||
boolean isActive() {
|
boolean isActive() {
|
||||||
return active;
|
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.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
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.lucene.util.LuceneTestCase.Slow;
|
||||||
import org.apache.solr.JSONTestUtil;
|
import org.apache.solr.JSONTestUtil;
|
||||||
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
|
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
|
||||||
|
@ -65,6 +67,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@Slow
|
@Slow
|
||||||
@SuppressSSL(bugUrl = "https://issues.apache.org/jira/browse/SOLR-5776")
|
@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 {
|
public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package org.apache.solr.metrics.reporters;
|
package org.apache.solr.metrics.reporters;
|
||||||
|
|
||||||
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -34,14 +35,18 @@ import org.apache.solr.metrics.SolrMetricManager;
|
||||||
import org.apache.solr.metrics.SolrMetricReporter;
|
import org.apache.solr.metrics.SolrMetricReporter;
|
||||||
import org.apache.solr.util.TestHarness;
|
import org.apache.solr.util.TestHarness;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SolrSlf4jReporterTest extends SolrTestCaseJ4 {
|
public class SolrSlf4jReporterTest extends SolrTestCaseJ4 {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReporter() throws Exception {
|
public void testReporter() throws Exception {
|
||||||
|
ensureLoggingConfiguredAppropriately();
|
||||||
LogWatcherConfig watcherCfg = new LogWatcherConfig(true, null, null, 100);
|
LogWatcherConfig watcherCfg = new LogWatcherConfig(true, null, null, 100);
|
||||||
LogWatcher watcher = LogWatcher.newRegisteredLogWatcher(watcherCfg, null);
|
LogWatcher watcher = LogWatcher.newRegisteredLogWatcher(watcherCfg, null);
|
||||||
watcher.setThreshold("INFO");
|
watcher.setThreshold("INFO");
|
||||||
|
@ -78,19 +83,20 @@ public class SolrSlf4jReporterTest extends SolrTestCaseJ4 {
|
||||||
}
|
}
|
||||||
Thread.sleep(5000);
|
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);
|
SolrDocumentList history = watcher.getHistory(-1, null);
|
||||||
// dot-separated names are treated like class names and collapsed
|
// dot-separated names are treated like class names and collapsed
|
||||||
// in regular log output, but here we get the full name
|
// in regular log output, but here we get the full name
|
||||||
if (history.stream().filter(d -> "solr.node".equals(d.getFirstValue("logger"))).count() == 0) {
|
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) {
|
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