diff --git a/lucene/ivy-versions.properties b/lucene/ivy-versions.properties
index e6179bb894d..d1994c21f97 100644
--- a/lucene/ivy-versions.properties
+++ b/lucene/ivy-versions.properties
@@ -58,13 +58,12 @@ com.sun.jersey.version = 1.19
/commons-io/commons-io = 2.5
/commons-logging/commons-logging = 1.1.3
/de.l3s.boilerpipe/boilerpipe = 1.1.0
-/info.ganglia.gmetric4j/gmetric4j = 1.0.7
-io.dropwizard.metrics.version = 3.2.6
+io.dropwizard.metrics.version = 4.0.5
/io.dropwizard.metrics/metrics-core = ${io.dropwizard.metrics.version}
-/io.dropwizard.metrics/metrics-ganglia = ${io.dropwizard.metrics.version}
/io.dropwizard.metrics/metrics-graphite = ${io.dropwizard.metrics.version}
/io.dropwizard.metrics/metrics-jetty9 = ${io.dropwizard.metrics.version}
+/io.dropwizard.metrics/metrics-jmx = ${io.dropwizard.metrics.version}
/io.dropwizard.metrics/metrics-jvm = ${io.dropwizard.metrics.version}
io.netty.netty-all.version = 4.0.52.Final
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index ac7a63a2c41..dc905014d66 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -98,6 +98,9 @@ Upgrade Notes
now Solr followed an obscure convention of updating only the first collection from the list, which usually was not what
the user intended. This change explicitly rejects such update requests.
+* SolrGangliaReporter has been removed from Solr because support for Ganglia has been removed from Dropwizard Metrics 4
+ due to a transitive dependency on LGPL.
+
New Features
----------------------
@@ -284,6 +287,8 @@ Other Changes
* SOLR-13409: Disable HTML directory listings in admin interface to prevent possible security issues (Uwe Schindler)
+* SOLR-12461: Upgrade Dropwizard Metrics to 4.0.5 release. (ab)
+
================== 8.0.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
diff --git a/solr/bin/solr.in.sh b/solr/bin/solr.in.sh
index 453796f46b7..b67f7701b73 100644
--- a/solr/bin/solr.in.sh
+++ b/solr/bin/solr.in.sh
@@ -69,7 +69,7 @@
# Set to true to activate the JMX RMI connector to allow remote JMX client applications
# to monitor the JVM hosting Solr; set to "false" to disable that behavior
# (false is recommended in production environments)
-#ENABLE_REMOTE_JMX_OPTS="false"
+ENABLE_REMOTE_JMX_OPTS="true"
# The script will use SOLR_PORT+10000 for the RMI_PORT or you can set it here
# RMI_PORT=18983
diff --git a/solr/core/src/java/org/apache/solr/metrics/MetricSuppliers.java b/solr/core/src/java/org/apache/solr/metrics/MetricSuppliers.java
index 9f0d12183bf..e4f5b6418b2 100644
--- a/solr/core/src/java/org/apache/solr/metrics/MetricSuppliers.java
+++ b/solr/core/src/java/org/apache/solr/metrics/MetricSuppliers.java
@@ -17,6 +17,8 @@
package org.apache.solr.metrics;
import java.lang.invoke.MethodHandles;
+import java.lang.management.ManagementFactory;
+import java.lang.management.ThreadMXBean;
import java.util.concurrent.TimeUnit;
import com.codahale.metrics.Clock;
@@ -58,7 +60,17 @@ public class MetricSuppliers {
}
}
- private static final Clock CPU_CLOCK = new Clock.CpuTimeClock();
+ // back-compat implementation, no longer present in metrics-4
+ private static final class CpuTimeClock extends Clock {
+ private static final ThreadMXBean THREAD_MX_BEAN = ManagementFactory.getThreadMXBean();
+
+ @Override
+ public long getTick() {
+ return THREAD_MX_BEAN.getCurrentThreadCpuTime();
+ }
+ }
+
+ private static final Clock CPU_CLOCK = new CpuTimeClock();
private static final Clock USER_CLOCK = new Clock.UserTimeClock();
/** Clock type parameter. */
@@ -73,7 +85,7 @@ public class MetricSuppliers {
* or initArgs:
*
* - clock - (string) can be set to {@link #CLOCK_USER} for {@link com.codahale.metrics.Clock.UserTimeClock} or
- * {@link #CLOCK_CPU} for {@link com.codahale.metrics.Clock.CpuTimeClock}. If not set then the value of
+ * {@link #CLOCK_CPU} for {@link CpuTimeClock}. If not set then the value of
* {@link Clock#defaultClock()} will be used.
*
*/
diff --git a/solr/core/src/java/org/apache/solr/metrics/reporters/SolrGangliaReporter.java b/solr/core/src/java/org/apache/solr/metrics/reporters/SolrGangliaReporter.java
deleted file mode 100644
index 8d77a023c63..00000000000
--- a/solr/core/src/java/org/apache/solr/metrics/reporters/SolrGangliaReporter.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * 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.reporters;
-
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
-import com.codahale.metrics.MetricFilter;
-import com.codahale.metrics.ganglia.GangliaReporter;
-import info.ganglia.gmetric4j.gmetric.GMetric;
-
-import org.apache.solr.metrics.FilteringSolrMetricReporter;
-import org.apache.solr.metrics.SolrMetricManager;
-
-/**
- *
- */
-public class SolrGangliaReporter extends FilteringSolrMetricReporter {
-
- private String host = null;
- private int port = -1;
- private boolean multicast;
- private String instancePrefix = null;
- private boolean testing;
- private GangliaReporter reporter;
-
- private static final ReporterClientCache serviceRegistry = new ReporterClientCache<>();
-
- // for unit tests
- GMetric ganglia = null;
-
- /**
- * Create a Ganglia reporter for metrics managed in a named registry.
- *
- * @param metricManager metric manager instance that manages the selected registry
- * @param registryName registry to use, one of registries managed by
- * {@link SolrMetricManager}
- */
- public SolrGangliaReporter(SolrMetricManager metricManager, String registryName) {
- super(metricManager, registryName);
- }
-
- public void setHost(String host) {
- this.host = host;
- }
-
- public void setPort(int port) {
- this.port = port;
- }
-
- public void setPrefix(String prefix) {
- this.instancePrefix = prefix;
- }
-
- public void setMulticast(boolean multicast) {
- this.multicast = multicast;
- }
-
- // only for unit tests!
- public void setTesting(boolean testing) {
- this.testing = testing;
- }
-
- void setGMetric(GMetric ganglia) {
- this.ganglia = ganglia;
- }
-
- @Override
- protected void doInit() {
- if (!testing) {
- start();
- }
- }
-
- @Override
- protected void validate() throws IllegalStateException {
- if (host == null) {
- throw new IllegalStateException("Init argument 'host' must be set to a valid Ganglia server name.");
- }
- if (port == -1) {
- throw new IllegalStateException("Init argument 'port' must be set to a valid Ganglia server port.");
- }
- if (period < 1) {
- throw new IllegalStateException("Init argument 'period' is in time unit 'seconds' and must be at least 1.");
- }
- }
-
- //this is a separate method for unit tests
- void start() {
- if (!testing) {
- String id = host + ":" + port + ":" + multicast;
- ganglia = serviceRegistry.getOrCreate(id, () -> new GMetric(host, port,
- multicast ? GMetric.UDPAddressingMode.MULTICAST : GMetric.UDPAddressingMode.UNICAST,
- 1));
- if (ganglia == null) {
- return;
- }
- }
- if (instancePrefix == null) {
- instancePrefix = registryName;
- } else {
- instancePrefix = instancePrefix + "." + registryName;
- }
- GangliaReporter.Builder builder = GangliaReporter
- .forRegistry(metricManager.registry(registryName))
- .convertRatesTo(TimeUnit.SECONDS)
- .convertDurationsTo(TimeUnit.MILLISECONDS)
- .prefixedWith(instancePrefix);
- final MetricFilter filter = newMetricFilter();
- builder = builder.filter(filter);
- reporter = builder.build(ganglia);
- reporter.start(period, TimeUnit.SECONDS);
- }
-
- @Override
- public void close() throws IOException {
- if (reporter != null) {
- reporter.close();
- }
- }
-}
diff --git a/solr/core/src/java/org/apache/solr/metrics/reporters/SolrJmxReporter.java b/solr/core/src/java/org/apache/solr/metrics/reporters/SolrJmxReporter.java
index fd927b12fb3..468ba602719 100644
--- a/solr/core/src/java/org/apache/solr/metrics/reporters/SolrJmxReporter.java
+++ b/solr/core/src/java/org/apache/solr/metrics/reporters/SolrJmxReporter.java
@@ -21,7 +21,6 @@ import javax.management.MBeanServer;
import java.lang.invoke.MethodHandles;
import java.util.Locale;
-import com.codahale.metrics.JmxReporter;
import com.codahale.metrics.MetricFilter;
import com.codahale.metrics.MetricRegistry;
@@ -37,7 +36,7 @@ import org.slf4j.LoggerFactory;
/**
* A {@link SolrMetricReporter} that finds (or creates) a MBeanServer from
* the given configuration and registers metrics to it with JMX.
- * NOTE: {@link JmxReporter} that this class uses exports only newly added metrics (it doesn't
+ *
NOTE: {@link com.codahale.metrics.jmx.JmxReporter} that this class uses exports only newly added metrics (it doesn't
* process already existing metrics in a registry)
*/
public class SolrJmxReporter extends FilteringSolrMetricReporter {
diff --git a/solr/core/src/java/org/apache/solr/metrics/reporters/jmx/JmxMetricsReporter.java b/solr/core/src/java/org/apache/solr/metrics/reporters/jmx/JmxMetricsReporter.java
index f7a0127cac6..f7fb066ab83 100644
--- a/solr/core/src/java/org/apache/solr/metrics/reporters/jmx/JmxMetricsReporter.java
+++ b/solr/core/src/java/org/apache/solr/metrics/reporters/jmx/JmxMetricsReporter.java
@@ -37,7 +37,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import com.codahale.metrics.Counter;
-import com.codahale.metrics.DefaultObjectNameFactory;
+import com.codahale.metrics.jmx.DefaultObjectNameFactory;
import com.codahale.metrics.Gauge;
import com.codahale.metrics.Histogram;
import com.codahale.metrics.Meter;
@@ -46,7 +46,7 @@ import com.codahale.metrics.Metric;
import com.codahale.metrics.MetricFilter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.MetricRegistryListener;
-import com.codahale.metrics.ObjectNameFactory;
+import com.codahale.metrics.jmx.ObjectNameFactory;
import com.codahale.metrics.Reporter;
import com.codahale.metrics.Timer;
import org.apache.solr.metrics.MetricsMap;
@@ -55,7 +55,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * This is a modified copy of Dropwizard's {@link com.codahale.metrics.JmxReporter} and classes that it internally uses,
+ * This is a modified copy of Dropwizard's {@link com.codahale.metrics.jmx.JmxReporter} and classes that it internally uses,
* with a few important differences:
*
* - this class knows that it can directly use {@link MetricsMap} as a dynamic MBean.
diff --git a/solr/core/src/java/org/apache/solr/metrics/reporters/jmx/JmxObjectNameFactory.java b/solr/core/src/java/org/apache/solr/metrics/reporters/jmx/JmxObjectNameFactory.java
index 056a35ac8ee..36eb83a88e1 100644
--- a/solr/core/src/java/org/apache/solr/metrics/reporters/jmx/JmxObjectNameFactory.java
+++ b/solr/core/src/java/org/apache/solr/metrics/reporters/jmx/JmxObjectNameFactory.java
@@ -21,7 +21,7 @@ import javax.management.ObjectName;
import java.util.Arrays;
-import com.codahale.metrics.ObjectNameFactory;
+import com.codahale.metrics.jmx.ObjectNameFactory;
import org.apache.solr.metrics.SolrMetricInfo;
/**
diff --git a/solr/core/src/test-files/solr/solr-gangliareporter.xml b/solr/core/src/test-files/solr/solr-gangliareporter.xml
deleted file mode 100644
index 432738877d1..00000000000
--- a/solr/core/src/test-files/solr/solr-gangliareporter.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
- localhost
- 10000
-
- 1
- test
- CONTAINER.cores
-
- true
-
-
-
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java
index 1730355ab50..ee0f665729d 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java
@@ -134,7 +134,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
assertNotNull(values.get("metrics"));
values = (NamedList) values.get("metrics");
assertEquals(1, values.size());
- assertEquals(11, ((NamedList)values.get("solr.node")).size());
+ assertEquals(13, ((NamedList)values.get("solr.node")).size());
assertNotNull(values.get("solr.node"));
values = (NamedList) values.get("solr.node");
assertNotNull(values.get("CONTAINER.cores.lazy")); // this is a gauge node
diff --git a/solr/core/src/test/org/apache/solr/metrics/reporters/SolrGangliaReporterTest.java b/solr/core/src/test/org/apache/solr/metrics/reporters/SolrGangliaReporterTest.java
deleted file mode 100644
index 23230cd8042..00000000000
--- a/solr/core/src/test/org/apache/solr/metrics/reporters/SolrGangliaReporterTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.reporters;
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import info.ganglia.gmetric4j.gmetric.GMetric;
-import info.ganglia.gmetric4j.gmetric.GMetricSlope;
-import info.ganglia.gmetric4j.gmetric.GMetricType;
-import org.apache.commons.io.FileUtils;
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.core.CoreContainer;
-import org.apache.solr.core.NodeConfig;
-import org.apache.solr.core.SolrResourceLoader;
-import org.apache.solr.core.SolrXmlConfig;
-import org.apache.solr.metrics.SolrMetricManager;
-import org.apache.solr.metrics.SolrMetricReporter;
-import org.apache.solr.util.TestHarness;
-import org.junit.Test;
-
-import static org.mockito.Mockito.*;
-
-/**
- *
- */
-public class SolrGangliaReporterTest extends SolrTestCaseJ4 {
- @Test
- public void testReporter() throws Exception {
- assumeWorkingMockito();
-
- Path home = Paths.get(TEST_HOME());
- // define these properties, they are used in solrconfig.xml
- System.setProperty("solr.test.sys.prop1", "propone");
- System.setProperty("solr.test.sys.prop2", "proptwo");
-
- GMetric ganglia = mock(GMetric.class);
- final List names = new ArrayList<>();
- doAnswer(invocation -> {
- final Object[] args = invocation.getArguments();
- names.add((String)args[0]);
- return null;
- }).when(ganglia).announce(anyString(), anyString(), any(GMetricType.class), anyString(), any(GMetricSlope.class), anyInt(), anyInt(), anyString());
- String solrXml = FileUtils.readFileToString(Paths.get(home.toString(), "solr-gangliareporter.xml").toFile(), "UTF-8");
- NodeConfig cfg = SolrXmlConfig.fromString(new SolrResourceLoader(home), solrXml);
- CoreContainer cc = createCoreContainer(cfg,
- new TestHarness.TestCoresLocator(DEFAULT_TEST_CORENAME, initCoreDataDir.getAbsolutePath(), "solrconfig.xml", "schema.xml"));
- h.coreName = DEFAULT_TEST_CORENAME;
- SolrMetricManager metricManager = cc.getMetricManager();
- Map reporters = metricManager.getReporters("solr.node");
- assertTrue(reporters.toString(), reporters.size() >= 1);
- SolrMetricReporter reporter = reporters.get("test");
- assertNotNull(reporter);
- assertTrue(reporter instanceof SolrGangliaReporter);
- SolrGangliaReporter gangliaReporter = (SolrGangliaReporter)reporter;
- gangliaReporter.setGMetric(ganglia);
- gangliaReporter.start();
- Thread.sleep(5000);
- assertTrue(names.size() >= 3);
- String[] frozenNames = (String[])names.toArray(new String[names.size()]);
- for (String name : frozenNames) {
- assertTrue(name, name.startsWith("test.solr.node.CONTAINER.cores."));
- }
- }
-
-}
diff --git a/solr/licenses/metrics-core-3.2.6.jar.sha1 b/solr/licenses/metrics-core-3.2.6.jar.sha1
deleted file mode 100644
index 13fae6d0b21..00000000000
--- a/solr/licenses/metrics-core-3.2.6.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-62fe170cffeded1cef60e9e3402a93b45ce14327
diff --git a/solr/licenses/metrics-core-4.0.5.jar.sha1 b/solr/licenses/metrics-core-4.0.5.jar.sha1
new file mode 100644
index 00000000000..f5e12e83aa1
--- /dev/null
+++ b/solr/licenses/metrics-core-4.0.5.jar.sha1
@@ -0,0 +1 @@
+b81ef162970cdb9f4512ee2da09715a856ff4c4c
diff --git a/solr/licenses/metrics-ganglia-3.2.6.jar.sha1 b/solr/licenses/metrics-ganglia-3.2.6.jar.sha1
deleted file mode 100644
index 32c9d30a57d..00000000000
--- a/solr/licenses/metrics-ganglia-3.2.6.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-a44039835eafd2dad8842a9ed16a60c088c5b7ef
diff --git a/solr/licenses/metrics-graphite-3.2.6.jar.sha1 b/solr/licenses/metrics-graphite-3.2.6.jar.sha1
deleted file mode 100644
index 26a1bbce30c..00000000000
--- a/solr/licenses/metrics-graphite-3.2.6.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-ecbc470e9097bb3d7ff0232cca47f3badde2e20b
diff --git a/solr/licenses/metrics-graphite-4.0.5.jar.sha1 b/solr/licenses/metrics-graphite-4.0.5.jar.sha1
new file mode 100644
index 00000000000..2aa9abb956e
--- /dev/null
+++ b/solr/licenses/metrics-graphite-4.0.5.jar.sha1
@@ -0,0 +1 @@
+76e8758356373d5aed5abacbda429b38f6e8fa98
diff --git a/solr/licenses/metrics-jetty9-3.2.6.jar.sha1 b/solr/licenses/metrics-jetty9-3.2.6.jar.sha1
deleted file mode 100644
index 5d7bfa49dd4..00000000000
--- a/solr/licenses/metrics-jetty9-3.2.6.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-5dae1c13d8607663fbc7b22cf8c05aacd22f802e
diff --git a/solr/licenses/metrics-jetty9-4.0.5.jar.sha1 b/solr/licenses/metrics-jetty9-4.0.5.jar.sha1
new file mode 100644
index 00000000000..228b179faa1
--- /dev/null
+++ b/solr/licenses/metrics-jetty9-4.0.5.jar.sha1
@@ -0,0 +1 @@
+87f3b49a7377e56f62046875d394ed0028b37690
diff --git a/solr/licenses/metrics-jmx-4.0.5.jar.sha1 b/solr/licenses/metrics-jmx-4.0.5.jar.sha1
new file mode 100644
index 00000000000..b70a07de05d
--- /dev/null
+++ b/solr/licenses/metrics-jmx-4.0.5.jar.sha1
@@ -0,0 +1 @@
+d7be4ddd7ba674ee8be1d23d883fb3ca68ee1d54
diff --git a/solr/licenses/metrics-ganglia-LICENSE-ASL.txt b/solr/licenses/metrics-jmx-LICENSE-ASL.txt
similarity index 100%
rename from solr/licenses/metrics-ganglia-LICENSE-ASL.txt
rename to solr/licenses/metrics-jmx-LICENSE-ASL.txt
diff --git a/solr/licenses/metrics-ganglia-NOTICE.txt b/solr/licenses/metrics-jmx-NOTICE.txt
similarity index 100%
rename from solr/licenses/metrics-ganglia-NOTICE.txt
rename to solr/licenses/metrics-jmx-NOTICE.txt
diff --git a/solr/licenses/metrics-jvm-3.2.6.jar.sha1 b/solr/licenses/metrics-jvm-3.2.6.jar.sha1
deleted file mode 100644
index 219d02bb0b5..00000000000
--- a/solr/licenses/metrics-jvm-3.2.6.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-a7a475393fe47dfee2042415430da3f01d4fe94e
diff --git a/solr/licenses/metrics-jvm-4.0.5.jar.sha1 b/solr/licenses/metrics-jvm-4.0.5.jar.sha1
new file mode 100644
index 00000000000..176a65f9ff1
--- /dev/null
+++ b/solr/licenses/metrics-jvm-4.0.5.jar.sha1
@@ -0,0 +1 @@
+09f6f1e6c1db440d9ad4c3114f17be40f66bb399
diff --git a/solr/server/ivy.xml b/solr/server/ivy.xml
index 6d1f11e4691..29a66e980a3 100644
--- a/solr/server/ivy.xml
+++ b/solr/server/ivy.xml
@@ -39,9 +39,8 @@
+
-
-