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: * */ 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: *