use of org.apache.solr.core.SolrInfoBean in project lucene-solr by apache.
the class SolrInfoBeanTest method testCallMBeanInfo.
/**
* Gets a list of everything we can find in the classpath and makes sure it has
* a name, description, etc...
*/
public void testCallMBeanInfo() throws Exception {
List<Class> classes = new ArrayList<>();
classes.addAll(getClassesForPackage(StandardRequestHandler.class.getPackage().getName()));
classes.addAll(getClassesForPackage(SearchComponent.class.getPackage().getName()));
classes.addAll(getClassesForPackage(LukeRequestHandler.class.getPackage().getName()));
classes.addAll(getClassesForPackage(DefaultSolrHighlighter.class.getPackage().getName()));
classes.addAll(getClassesForPackage(LRUCache.class.getPackage().getName()));
// System.out.println(classes);
int checked = 0;
SolrMetricManager metricManager = h.getCoreContainer().getMetricManager();
String registry = h.getCore().getCoreMetricManager().getRegistryName();
String scope = TestUtil.randomSimpleString(random(), 2, 10);
for (Class clazz : classes) {
if (SolrInfoBean.class.isAssignableFrom(clazz)) {
try {
SolrInfoBean info = (SolrInfoBean) clazz.newInstance();
if (info instanceof SolrMetricProducer) {
((SolrMetricProducer) info).initializeMetrics(metricManager, registry, scope);
}
//System.out.println( info.getClass() );
assertNotNull(info.getName());
assertNotNull(info.getDescription());
assertNotNull(info.getCategory());
if (info instanceof LRUCache) {
continue;
}
assertNotNull(info.toString());
checked++;
} catch (InstantiationException ex) {
// expected...
//System.out.println( "unable to initialize: "+clazz );
}
}
}
assertTrue("there are at least 10 SolrInfoBean that should be found in the classpath, found " + checked, checked > 10);
}
use of org.apache.solr.core.SolrInfoBean in project lucene-solr by apache.
the class PluginInfoHandler method getSolrInfoBeans.
private static SimpleOrderedMap<Object> getSolrInfoBeans(SolrCore core, boolean stats) {
SimpleOrderedMap<Object> list = new SimpleOrderedMap<>();
for (SolrInfoBean.Category cat : SolrInfoBean.Category.values()) {
SimpleOrderedMap<Object> category = new SimpleOrderedMap<>();
list.add(cat.name(), category);
Map<String, SolrInfoBean> reg = core.getInfoRegistry();
for (Map.Entry<String, SolrInfoBean> entry : reg.entrySet()) {
SolrInfoBean m = entry.getValue();
if (m.getCategory() != cat)
continue;
String na = "Not Declared";
SimpleOrderedMap<Object> info = new SimpleOrderedMap<>();
category.add(entry.getKey(), info);
info.add(NAME, (m.getName() != null ? m.getName() : na));
info.add("description", (m.getDescription() != null ? m.getDescription() : na));
if (stats) {
info.add("stats", m.getMetricsSnapshot());
}
}
}
return list;
}
use of org.apache.solr.core.SolrInfoBean in project lucene-solr by apache.
the class SolrInfoMBeanHandler method getMBeanInfo.
protected NamedList<NamedList<NamedList<Object>>> getMBeanInfo(SolrQueryRequest req) {
NamedList<NamedList<NamedList<Object>>> cats = new NamedList<>();
String[] requestedCats = req.getParams().getParams("cat");
if (null == requestedCats || 0 == requestedCats.length) {
for (SolrInfoBean.Category cat : SolrInfoBean.Category.values()) {
cats.add(cat.name(), new SimpleOrderedMap<NamedList<Object>>());
}
} else {
for (String catName : requestedCats) {
cats.add(catName, new SimpleOrderedMap<NamedList<Object>>());
}
}
Set<String> requestedKeys = arrayToSet(req.getParams().getParams("key"));
Map<String, SolrInfoBean> reg = req.getCore().getInfoRegistry();
for (Map.Entry<String, SolrInfoBean> entry : reg.entrySet()) {
addMBean(req, cats, requestedKeys, entry.getKey(), entry.getValue());
}
for (SolrInfoBean infoMBean : req.getCore().getCoreContainer().getResourceLoader().getInfoMBeans()) {
addMBean(req, cats, requestedKeys, infoMBean.getName(), infoMBean);
}
return cats;
}
use of org.apache.solr.core.SolrInfoBean in project lucene-solr by apache.
the class SolrIndexSearcher method register.
/**
* Register sub-objects such as caches and our own metrics
*/
public void register() {
final Map<String, SolrInfoBean> infoRegistry = core.getInfoRegistry();
// register self
infoRegistry.put(STATISTICS_KEY, this);
infoRegistry.put(name, this);
for (SolrCache cache : cacheList) {
cache.setState(SolrCache.State.LIVE);
infoRegistry.put(cache.name(), cache);
}
SolrMetricManager manager = core.getCoreContainer().getMetricManager();
String registry = core.getCoreMetricManager().getRegistryName();
for (SolrCache cache : cacheList) {
cache.initializeMetrics(manager, registry, SolrMetricManager.mkName(cache.name(), STATISTICS_KEY));
}
initializeMetrics(manager, registry, STATISTICS_KEY);
registerTime = new Date();
}
Aggregations