mirror of https://github.com/apache/lucene.git
SOLR-13712: JMX MBeans are not exposed because of race condition between creating platform mbean server and registering mbeans
This commit is contained in:
parent
0dfbf557ba
commit
2ba61c8fb9
|
@ -246,6 +246,9 @@ Bug Fixes
|
|||
* SOLR-13417: Handle stats aggregation on date and string fields in SolrJ's JSON facet response processing
|
||||
(Jason Gerlowski, Munendra S N)
|
||||
|
||||
* SOLR-13712: JMX MBeans are not exposed because of race condition between creating platform mbean server and
|
||||
registering mbeans. (shalin)
|
||||
|
||||
Other Changes
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ public class SolrJmxReporter extends FilteringSolrMetricReporter {
|
|||
protected synchronized void doInit() {
|
||||
if (serviceUrl != null && agentId != null) {
|
||||
mBeanServer = JmxUtil.findFirstMBeanServer();
|
||||
log.warn("No more than one of serviceUrl({}) and agentId({}) should be configured, using first MBeanServer instead of configuration.",
|
||||
log.warn("No more than one of serviceUrl({}) and agentId({}) should be configured, using first MBeanServer {} instead of configuration.",
|
||||
serviceUrl, agentId, mBeanServer);
|
||||
} else if (serviceUrl != null) {
|
||||
// reuse existing services
|
||||
|
|
|
@ -28,7 +28,6 @@ import javax.management.Query;
|
|||
import javax.management.QueryExp;
|
||||
import java.io.Closeable;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
@ -157,9 +156,6 @@ public class JmxMetricsReporter implements Reporter, Closeable {
|
|||
}
|
||||
|
||||
public JmxMetricsReporter build() {
|
||||
if (mBeanServer == null) {
|
||||
mBeanServer = ManagementFactory.getPlatformMBeanServer();
|
||||
}
|
||||
if (tag == null) {
|
||||
tag = Integer.toHexString(this.hashCode());
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import javax.management.remote.JMXConnectorServerFactory;
|
|||
import javax.management.remote.JMXServiceURL;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -31,12 +32,16 @@ import java.util.List;
|
|||
public final class JmxUtil {
|
||||
|
||||
/**
|
||||
* Retrieve the first MBeanServer found.
|
||||
* Retrieve the first MBeanServer found and if not found return the platform mbean server
|
||||
*
|
||||
* @return the first MBeanServer found
|
||||
*/
|
||||
public static MBeanServer findFirstMBeanServer() {
|
||||
return findMBeanServerForAgentId(null);
|
||||
MBeanServer mBeanServer = findMBeanServerForAgentId(null);
|
||||
if (mBeanServer == null) {
|
||||
return ManagementFactory.getPlatformMBeanServer();
|
||||
}
|
||||
return mBeanServer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue