SOLR-9374: Speed up Jmx MBean retrieval for FieldCache

This commit is contained in:
Shalin Shekhar Mangar 2016-08-28 01:04:36 +05:30
parent 4f316bc199
commit b1b933eb43
3 changed files with 10 additions and 2 deletions

View File

@ -92,6 +92,8 @@ Bug Fixes
Optimizations Optimizations
---------------------- ----------------------
* SOLR-9374: Speed up Jmx MBean retrieval for FieldCache. (Tim Owen via shalin)
Other Changes Other Changes
---------------------- ----------------------

View File

@ -61,12 +61,14 @@ public class SolrFieldCacheMBean implements JmxAugmentedSolrInfoMBean {
private NamedList getStats(boolean listEntries) { private NamedList getStats(boolean listEntries) {
NamedList stats = new SimpleOrderedMap(); NamedList stats = new SimpleOrderedMap();
if (listEntries) {
String[] entries = UninvertingReader.getUninvertedStats(); String[] entries = UninvertingReader.getUninvertedStats();
stats.add("entries_count", entries.length); stats.add("entries_count", entries.length);
if (listEntries) {
for (int i = 0; i < entries.length; i++) { for (int i = 0; i < entries.length; i++) {
stats.add("entry#" + i, entries[i]); stats.add("entry#" + i, entries[i]);
} }
} else {
stats.add("entries_count", UninvertingReader.getUninvertedStatsSize());
} }
return stats; return stats;
} }

View File

@ -388,4 +388,8 @@ public class UninvertingReader extends FilterLeafReader {
} }
return info; return info;
} }
public static int getUninvertedStatsSize() {
return FieldCache.DEFAULT.getCacheEntries().length;
}
} }