SOLR-4302: New parameter 'indexInfo' (defaults to true) in CoreAdmin STATUS command can be used to omit index specific information

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1432901 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2013-01-14 12:44:45 +00:00
parent 93b0a15183
commit 55484336a6
4 changed files with 28 additions and 12 deletions

View File

@ -207,6 +207,9 @@ New Features
* SOLR-2201: DIH's "formatDate" function now supports a timezone as an optional
fourth parameter (James Dyer, Mark Waddle)
* SOLR-4302: New parameter 'indexInfo' (defaults to true) in CoreAdmin STATUS
command can be used to omit index specific information (Shahar Davidson via shalin)
Optimizations
----------------------

View File

@ -689,6 +689,8 @@ public class CoreAdminHandler extends RequestHandlerBase {
SolrParams params = req.getParams();
String cname = params.get(CoreAdminParams.CORE);
String indexInfo = params.get(CoreAdminParams.INDEX_INFO);
boolean isIndexInfoNeeded = Boolean.parseBoolean(null == indexInfo ? "true" : indexInfo);
boolean doPersist = false;
NamedList<Object> status = new SimpleOrderedMap<Object>();
Map<String,Exception> allFailures = coreContainer.getCoreInitFailures();
@ -696,7 +698,7 @@ public class CoreAdminHandler extends RequestHandlerBase {
if (cname == null) {
rsp.add("defaultCoreName", coreContainer.getDefaultCoreName());
for (String name : coreContainer.getCoreNames()) {
status.add(name, getCoreStatus(coreContainer, name));
status.add(name, getCoreStatus(coreContainer, name, isIndexInfoNeeded));
}
rsp.add("initFailures", allFailures);
} else {
@ -704,7 +706,7 @@ public class CoreAdminHandler extends RequestHandlerBase {
? Collections.singletonMap(cname, allFailures.get(cname))
: Collections.emptyMap();
rsp.add("initFailures", failures);
status.add(cname, getCoreStatus(coreContainer, cname));
status.add(cname, getCoreStatus(coreContainer, cname, isIndexInfoNeeded));
}
rsp.add("status", status);
doPersist = false; // no state change
@ -988,7 +990,7 @@ public class CoreAdminHandler extends RequestHandlerBase {
}
protected NamedList<Object> getCoreStatus(CoreContainer cores, String cname) throws IOException {
protected NamedList<Object> getCoreStatus(CoreContainer cores, String cname, boolean isIndexInfoNeeded) throws IOException {
NamedList<Object> info = new SimpleOrderedMap<Object>();
SolrCore core = cores.getCore(cname);
if (core != null) {
@ -1001,15 +1003,17 @@ public class CoreAdminHandler extends RequestHandlerBase {
info.add("schema", core.getSchemaResource());
info.add("startTime", new Date(core.getStartTime()));
info.add("uptime", System.currentTimeMillis() - core.getStartTime());
RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
try {
SimpleOrderedMap<Object> indexInfo = LukeRequestHandler.getIndexInfo(searcher.get().getIndexReader());
long size = getIndexSize(core);
indexInfo.add("sizeInBytes", size);
indexInfo.add("size", NumberUtils.readableSize(size));
info.add("index", indexInfo);
} finally {
searcher.decref();
if (isIndexInfoNeeded) {
RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
try {
SimpleOrderedMap<Object> indexInfo = LukeRequestHandler.getIndexInfo(searcher.get().getIndexReader());
long size = getIndexSize(core);
indexInfo.add("sizeInBytes", size);
indexInfo.add("size", NumberUtils.readableSize(size));
info.add("index", indexInfo);
} finally {
searcher.decref();
}
}
} finally {
core.close();

View File

@ -42,6 +42,7 @@ public class CoreAdminRequest extends SolrRequest
{
protected String core = null;
protected String other = null;
protected boolean isIndexInfoNeeded = true;
protected CoreAdminParams.CoreAdminAction action = null;
//a create core request
@ -383,6 +384,10 @@ public class CoreAdminRequest extends SolrRequest
{
this.other = otherCoreName;
}
public final void setIndexInfoNeeded(boolean isIndexInfoNeeded) {
this.isIndexInfoNeeded = isIndexInfoNeeded;
}
//---------------------------------------------------------------------------------------
//
@ -406,6 +411,7 @@ public class CoreAdminRequest extends SolrRequest
ModifiableSolrParams params = new ModifiableSolrParams();
params.set( CoreAdminParams.ACTION, action.toString() );
params.set( CoreAdminParams.CORE, core );
params.set(CoreAdminParams.INDEX_INFO, (isIndexInfoNeeded ? "true" : "false"));
if (other != null) {
params.set(CoreAdminParams.OTHER, other);
}

View File

@ -28,6 +28,9 @@ public interface CoreAdminParams
/** What Core are we talking about **/
public final static String CORE = "core";
/** Should the STATUS request include index info **/
public final static String INDEX_INFO = "indexInfo";
/** Persistent -- should it save the cores state? **/
public final static String PERSISTENT = "persistent";