added more thread-renaiming for search processes

pull/1/head
Michael Peter Christen 12 years ago
parent 900445d8e9
commit b30a7162fa

@ -48,7 +48,6 @@ import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryRequestBase; import org.apache.solr.request.SolrQueryRequestBase;
import org.apache.solr.request.SolrRequestInfo; import org.apache.solr.request.SolrRequestInfo;
import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.servlet.SolrRequestParsers;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import com.google.common.io.Files; import com.google.common.io.Files;
@ -62,7 +61,7 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo
private final CoreContainer cores; private final CoreContainer cores;
private final String defaultCoreName; private final String defaultCoreName;
private final SolrCore defaultCore; private final SolrCore defaultCore;
protected SolrRequestParsers adminRequestParser;
private final SearchHandler requestHandler; private final SearchHandler requestHandler;
private final File storagePath; private final File storagePath;
@ -149,6 +148,11 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo
public SolrQueryResponse query(SolrQueryRequest req) throws SolrException { public SolrQueryResponse query(SolrQueryRequest req) throws SolrException {
final long startTime = System.currentTimeMillis(); final long startTime = System.currentTimeMillis();
// during the solr query we set the thread name to the query string to get more debugging info in thread dumps
String q = req.getParams().get("q");
String threadname = Thread.currentThread().getName();
if (q != null) Thread.currentThread().setName("solr query: q = " + q);
SolrQueryResponse rsp = new SolrQueryResponse(); SolrQueryResponse rsp = new SolrQueryResponse();
NamedList<Object> responseHeader = new SimpleOrderedMap<Object>(); NamedList<Object> responseHeader = new SimpleOrderedMap<Object>();
responseHeader.add("params", req.getOriginalParams().toNamedList()); responseHeader.add("params", req.getOriginalParams().toNamedList());
@ -164,6 +168,7 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo
responseHeader.add("status", status); responseHeader.add("status", status);
responseHeader.add("QTime",(int) (System.currentTimeMillis() - startTime)); responseHeader.add("QTime",(int) (System.currentTimeMillis() - startTime));
if (q != null) Thread.currentThread().setName(threadname);
// return result // return result
return rsp; return rsp;
} }

@ -154,6 +154,11 @@ public class RemoteSolrConnector extends SolrServerConnector implements SolrConn
@Override @Override
public QueryResponse query(ModifiableSolrParams params) throws IOException { public QueryResponse query(ModifiableSolrParams params) throws IOException {
try { try {
// during the solr query we set the thread name to the query string to get more debugging info in thread dumps
String q = params.get("q");
String threadname = Thread.currentThread().getName();
if (q != null) Thread.currentThread().setName("solr query: q = " + q);
QueryRequest request = new QueryRequest(params); QueryRequest request = new QueryRequest(params);
ResponseParser responseParser = new XMLResponseParser(); ResponseParser responseParser = new XMLResponseParser();
request.setResponseParser(responseParser); request.setResponseParser(responseParser);
@ -161,6 +166,8 @@ public class RemoteSolrConnector extends SolrServerConnector implements SolrConn
NamedList<Object> result = server.request(request); NamedList<Object> result = server.request(request);
QueryResponse response = new QueryResponse(result, server); QueryResponse response = new QueryResponse(result, server);
response.setElapsedTime(System.currentTimeMillis() - t); response.setElapsedTime(System.currentTimeMillis() - t);
if (q != null) Thread.currentThread().setName(threadname);
return response; return response;
} catch (SolrServerException e) { } catch (SolrServerException e) {
throw new IOException(e); throw new IOException(e);

Loading…
Cancel
Save