Apache Solr open-source search software
SOLR-1843: new rootName attribute for <jmx /> configuration ... allows users to override the top level name for MBeans when exposed via JMX.
Chris M. Hostetter003cc244f8e5
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex f93f162e148..071060ff595 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -170,6 +170,12 @@ Optimizations* SOLR-1904: When facet.enum.cache.minDf > 0 and the base doc set is aSortedIntSet, convert to HashDocSet for better performance. (yonik)+* SOLR-1843: A new "rootName" attribute is now available when+ configuring <jmx/> in solrconfig.xml. If this attribute is set,+ Solr will use it as the root name for all MBeans Solr exposes via+ JMX. The default root name is "solr" followed by the core name.+ (Constantijn Visinescu, hossman)+Bug Fixes----------------------diff --git a/solr/src/java/org/apache/solr/core/JmxMonitoredMap.java b/solr/src/java/org/apache/solr/core/JmxMonitoredMap.javaindex b69d0da7a89..534218a0662 100644--- a/solr/src/java/org/apache/solr/core/JmxMonitoredMap.java+++ b/solr/src/java/org/apache/solr/core/JmxMonitoredMap.java@@ -53,15 +53,12 @@ public class JmxMonitoredMap<K, V> extendsprivate String jmxRootName;- public JmxMonitoredMap(String coreName, JmxConfiguration jmxConfig) {- jmxRootName = "solr" + (coreName == null ? "" : "/" + coreName);-- if (jmxConfig.agentId != null && jmxConfig.serviceUrl != null) {- throw new SolrException(- SolrException.ErrorCode.SERVER_ERROR,- "Incorrect JMX Configuration in solrconfig.xml, both agentId and serviceUrl cannot be specified at the same time");- }-+ public JmxMonitoredMap(final String coreName,+ final JmxConfiguration jmxConfig) {+ jmxRootName = (null != jmxConfig.rootName ?+ jmxConfig.rootName+ : ("solr" + (null != coreName ? "/" + coreName : "")));+if (jmxConfig.serviceUrl == null) {List<MBeanServer> servers = null;@@ -78,13 +75,12 @@ public class JmxMonitoredMap<K, V> extends}if (servers == null || servers.isEmpty()) {- LOG- .info("No JMX servers found, not exposing Solr information with JMX.");+ LOG.info("No JMX servers found, not exposing Solr information with JMX.");return;}server = servers.get(0);LOG.info("JMX monitoring is enabled. Adding Solr mbeans to JMX Server: "- + server);+ + server);} else {try {// Create a new MBeanServer with the given serviceUrldiff --git a/solr/src/java/org/apache/solr/core/SolrConfig.java b/solr/src/java/org/apache/solr/core/SolrConfig.javaindex dfcde299b3e..e3ccaa737b8 100644--- a/solr/src/java/org/apache/solr/core/SolrConfig.java+++ b/solr/src/java/org/apache/solr/core/SolrConfig.java@@ -179,10 +179,13 @@ public class SolrConfig extends Config {Node jmx = (Node) getNode("jmx", false);if (jmx != null) {- jmxConfig = new JmxConfiguration(true, get("jmx/@agentId", null), get(- "jmx/@serviceUrl", null));+ jmxConfig = new JmxConfiguration(true,+ get("jmx/@agentId", null),+ get("jmx/@serviceUrl", null),+ get("jmx/@rootName", null));+} else {- jmxConfig = new JmxConfiguration(false, null, null);+ jmxConfig = new JmxConfiguration(false, null, null, null);}maxWarmingSearchers = getInt("query/maxWarmingSearchers",Integer.MAX_VALUE);@@ -319,15 +322,32 @@ public class SolrConfig extends Config {public static class JmxConfiguration {public boolean enabled = false;-public String agentId;-public String serviceUrl;+ public String rootName;- public JmxConfiguration(boolean enabled, String agentId, String serviceUrl) {+ @Deprecated+ public JmxConfiguration(boolean enabled,+ String agentId,+ String serviceUrl) {+ this(enabled,agentId,serviceUrl,null);+ }+ public JmxConfiguration(boolean enabled,+ String agentId,+ String serviceUrl,+ String rootName) {this.enabled = enabled;this.agentId = agentId;this.serviceUrl = serviceUrl;+ this.rootName = rootName;++ if (agentId != null && serviceUrl != null) {+ throw new SolrException+ (SolrException.ErrorCode.SERVER_ERROR,+ "Incorrect JMX Configuration in solrconfig.xml, "++ "both agentId and serviceUrl cannot be specified at the same time");+ }+}}