diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index c8579ba66c8..6b9a5bb9f50 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -105,6 +105,8 @@ Other Changes * SOLR-6178, LUCENE-5775: Deprecate JaspellLookupFactory. (Uwe Schindler, Mike McCandless) +* SOLR-5902: Corecontainer level mbeans are not exposed (noble) + ================== 4.9.0 ================== Versions of Major Components diff --git a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java index bc95767e5c8..9cbd048d54e 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java +++ b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java @@ -816,4 +816,7 @@ public class SolrResourceLoader implements ResourceLoader,Closeable public void close() throws IOException { IOUtils.close(classLoader); } + public List getInfoMBeans(){ + return Collections.unmodifiableList(infoMBeans); + } } diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SolrInfoMBeanHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/SolrInfoMBeanHandler.java index 36984401dfb..0c2b50dbeef 100644 --- a/solr/core/src/java/org/apache/solr/handler/admin/SolrInfoMBeanHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/admin/SolrInfoMBeanHandler.java @@ -34,6 +34,7 @@ import java.io.StringReader; import java.net.URL; import java.text.NumberFormat; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Set; @@ -131,38 +132,41 @@ public class SolrInfoMBeanHandler extends RequestHandlerBase { Map reg = req.getCore().getInfoRegistry(); for (Map.Entry entry : reg.entrySet()) { - String key = entry.getKey(); - SolrInfoMBean m = entry.getValue(); + addMBean(req, cats, requestedKeys, entry.getKey(),entry.getValue()); + } - if ( ! ( requestedKeys.isEmpty() || requestedKeys.contains(key) ) ) continue; - - NamedList> catInfo = cats.get(m.getCategory().name()); - if ( null == catInfo ) continue; - - NamedList mBeanInfo = new SimpleOrderedMap<>(); - mBeanInfo.add("class", m.getName()); - mBeanInfo.add("version", m.getVersion()); - mBeanInfo.add("description", m.getDescription()); - mBeanInfo.add("src", m.getSource()); - - // Use an external form - URL[] urls = m.getDocs(); - if(urls!=null) { - List docs = new ArrayList<>(urls.length); - for(URL url : urls) { - docs.add(url.toExternalForm()); - } - mBeanInfo.add("docs", docs); - } - - if (req.getParams().getFieldBool(key, "stats", false)) - mBeanInfo.add("stats", m.getStatistics()); - - catInfo.add(key, mBeanInfo); + for (SolrInfoMBean infoMBean : req.getCore().getCoreDescriptor().getCoreContainer().getResourceLoader().getInfoMBeans()) { + addMBean(req,cats,requestedKeys,infoMBean.getName(),infoMBean); } return cats; } + private void addMBean(SolrQueryRequest req, NamedList>> cats, Set requestedKeys, String key, SolrInfoMBean m) { + if ( ! ( requestedKeys.isEmpty() || requestedKeys.contains(key) ) ) return; + NamedList> catInfo = cats.get(m.getCategory().name()); + if ( null == catInfo ) return; + NamedList mBeanInfo = new SimpleOrderedMap<>(); + mBeanInfo.add("class", m.getName()); + mBeanInfo.add("version", m.getVersion()); + mBeanInfo.add("description", m.getDescription()); + mBeanInfo.add("src", m.getSource()); + + // Use an external form + URL[] urls = m.getDocs(); + if(urls!=null) { + List docs = new ArrayList<>(urls.length); + for(URL url : urls) { + docs.add(url.toExternalForm()); + } + mBeanInfo.add("docs", docs); + } + + if (req.getParams().getFieldBool(key, "stats", false)) + mBeanInfo.add("stats", m.getStatistics()); + + catInfo.add(key, mBeanInfo); + } + protected NamedList>> getDiff( NamedList>> ref, NamedList>> now, diff --git a/solr/core/src/test/org/apache/solr/handler/admin/MBeansHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/MBeansHandlerTest.java index 66ba14c25b9..f7992bb8d70 100644 --- a/solr/core/src/test/org/apache/solr/handler/admin/MBeansHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/admin/MBeansHandlerTest.java @@ -61,5 +61,13 @@ public class MBeansHandlerTest extends SolrTestCaseJ4 { //System.out.println("stats:"+stats); assertEquals("Was: 1, Now: 2, Delta: 1", stats.get("requests")); + + xml = h.query(req( + CommonParams.QT,"/admin/mbeans", + "stats","true", + "key","org.apache.solr.handler.admin.CollectionsHandler" + )); + NamedList>> nl = SolrInfoMBeanHandler.fromXML(xml); + assertNotNull( nl.get("QUERYHANDLER").get("org.apache.solr.handler.admin.CollectionsHandler")); } }