diff --git a/src/java/org/apache/solr/core/SolrCore.java b/src/java/org/apache/solr/core/SolrCore.java index c95b28e910c..3fe9099c7d4 100644 --- a/src/java/org/apache/solr/core/SolrCore.java +++ b/src/java/org/apache/solr/core/SolrCore.java @@ -568,7 +568,6 @@ public final class SolrCore { _searcher = newSearcherHolder; SolrIndexSearcher newSearcher = newSearcherHolder.get(); - SolrInfoRegistry.getRegistry().put("currentSearcher", newSearcher); newSearcher.register(); // register subitems (caches) log.info("Registered new searcher " + newSearcher); diff --git a/src/java/org/apache/solr/search/SolrIndexSearcher.java b/src/java/org/apache/solr/search/SolrIndexSearcher.java index a51546448f9..5e643d1da37 100644 --- a/src/java/org/apache/solr/search/SolrIndexSearcher.java +++ b/src/java/org/apache/solr/search/SolrIndexSearcher.java @@ -58,6 +58,8 @@ public class SolrIndexSearcher extends Searcher implements SolrInfoMBean { private final IndexSchema schema; private final String name; + private long openTime = System.currentTimeMillis(); + private long registerTime = 0; private final IndexSearcher searcher; private final IndexReader reader; private final boolean closeReader; @@ -134,6 +136,9 @@ public class SolrIndexSearcher extends Searcher implements SolrInfoMBean { cacheMap = noGenericCaches; cacheList= noCaches; } + + // register self + SolrInfoRegistry.getRegistry().put(this.name, this); } @@ -149,10 +154,14 @@ public class SolrIndexSearcher extends Searcher implements SolrInfoMBean { cache.setState(SolrCache.State.LIVE); SolrInfoRegistry.getRegistry().put(cache.name(), cache); } + registerTime=System.currentTimeMillis(); } public void close() throws IOException { + // unregister first, so no management actions are tried on a closing searcher. + SolrInfoRegistry.getRegistry().remove(name); + if (cachingEnabled) { StringBuilder sb = new StringBuilder(); sb.append("Closing ").append(name); @@ -1046,7 +1055,7 @@ public class SolrIndexSearcher extends Searcher implements SolrInfoMBean { } public String getDescription() { - return "the searcher that handles all index queries"; + return "index searcher"; } public Category getCategory() { @@ -1070,24 +1079,20 @@ public class SolrIndexSearcher extends Searcher implements SolrInfoMBean { } public NamedList getStatistics() { - /*** NamedList lst = new NamedList(); - lst.add("requests", numRequests); - lst.add("errors", numErrors); + lst.add("caching", cachingEnabled); + lst.add("numDocs", reader.numDocs()); + lst.add("maxDoc", reader.maxDoc()); + lst.add("readerImpl", reader.getClass().getSimpleName()); + lst.add("readerDir", reader.directory()); + lst.add("indexVersion", reader.getVersion()); + lst.add("openedAt", new Date(openTime)); + if (registerTime!=0) lst.add("registeredAt", new Date(registerTime)); return lst; - ***/ - return new NamedList(); } - - - - } - - - // Todo: counting only hit collector (for speed comparison w/ caching filters) // todo: fast term query // todo: do a both hit collector that can get a DocList and DocSet at the same time