From b30a7162fa393fa23941f997e328788835f0f2e9 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Tue, 6 Nov 2012 12:31:23 +0100 Subject: [PATCH] added more thread-renaiming for search processes --- .../federate/solr/connector/EmbeddedSolrConnector.java | 9 +++++++-- .../federate/solr/connector/RemoteSolrConnector.java | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java index 040ef9813..1cac872e4 100644 --- a/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java +++ b/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java @@ -48,7 +48,6 @@ import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.request.SolrQueryRequestBase; import org.apache.solr.request.SolrRequestInfo; import org.apache.solr.response.SolrQueryResponse; -import org.apache.solr.servlet.SolrRequestParsers; import org.xml.sax.SAXException; import com.google.common.io.Files; @@ -62,7 +61,7 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo private final CoreContainer cores; private final String defaultCoreName; private final SolrCore defaultCore; - protected SolrRequestParsers adminRequestParser; + private final SearchHandler requestHandler; private final File storagePath; @@ -149,6 +148,11 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo public SolrQueryResponse query(SolrQueryRequest req) throws SolrException { 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(); NamedList responseHeader = new SimpleOrderedMap(); responseHeader.add("params", req.getOriginalParams().toNamedList()); @@ -164,6 +168,7 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo responseHeader.add("status", status); responseHeader.add("QTime",(int) (System.currentTimeMillis() - startTime)); + if (q != null) Thread.currentThread().setName(threadname); // return result return rsp; } diff --git a/source/net/yacy/cora/federate/solr/connector/RemoteSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/RemoteSolrConnector.java index 40c008ae3..aa20414ae 100644 --- a/source/net/yacy/cora/federate/solr/connector/RemoteSolrConnector.java +++ b/source/net/yacy/cora/federate/solr/connector/RemoteSolrConnector.java @@ -154,6 +154,11 @@ public class RemoteSolrConnector extends SolrServerConnector implements SolrConn @Override public QueryResponse query(ModifiableSolrParams params) throws IOException { 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); ResponseParser responseParser = new XMLResponseParser(); request.setResponseParser(responseParser); @@ -161,6 +166,8 @@ public class RemoteSolrConnector extends SolrServerConnector implements SolrConn NamedList result = server.request(request); QueryResponse response = new QueryResponse(result, server); response.setElapsedTime(System.currentTimeMillis() - t); + + if (q != null) Thread.currentThread().setName(threadname); return response; } catch (SolrServerException e) { throw new IOException(e);