mirror of https://github.com/apache/lucene.git
SOLR-5902: Corecontainer level mbeans are not exposed
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1605081 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5f77544bce
commit
f2eacfd18b
|
@ -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
|
||||
|
|
|
@ -816,4 +816,7 @@ public class SolrResourceLoader implements ResourceLoader,Closeable
|
|||
public void close() throws IOException {
|
||||
IOUtils.close(classLoader);
|
||||
}
|
||||
public List<SolrInfoMBean> getInfoMBeans(){
|
||||
return Collections.unmodifiableList(infoMBeans);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String, SolrInfoMBean> reg = req.getCore().getInfoRegistry();
|
||||
for (Map.Entry<String, SolrInfoMBean> 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<NamedList<Object>> catInfo = cats.get(m.getCategory().name());
|
||||
if ( null == catInfo ) continue;
|
||||
|
||||
NamedList<Object> 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<String> 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<NamedList<NamedList<Object>>> cats, Set<String> requestedKeys, String key, SolrInfoMBean m) {
|
||||
if ( ! ( requestedKeys.isEmpty() || requestedKeys.contains(key) ) ) return;
|
||||
NamedList<NamedList<Object>> catInfo = cats.get(m.getCategory().name());
|
||||
if ( null == catInfo ) return;
|
||||
NamedList<Object> 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<String> 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<NamedList<NamedList<Object>>> getDiff(
|
||||
NamedList<NamedList<NamedList<Object>>> ref,
|
||||
NamedList<NamedList<NamedList<Object>>> now,
|
||||
|
|
|
@ -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<NamedList<NamedList<Object>>> nl = SolrInfoMBeanHandler.fromXML(xml);
|
||||
assertNotNull( nl.get("QUERYHANDLER").get("org.apache.solr.handler.admin.CollectionsHandler"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue