From e78320753583081c7402d66a259949ab85c8250e Mon Sep 17 00:00:00 2001 From: Noble Paul Date: Mon, 15 Apr 2019 11:10:06 +1000 Subject: [PATCH] SOLR-13395: make DebugComponent.getRequestId() public --- .../handler/component/DebugComponent.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java b/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java index 1f398a981f3..87076a0b00b 100644 --- a/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java +++ b/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java @@ -145,23 +145,27 @@ public class DebugComponent extends SearchComponent private void doDebugTrack(ResponseBuilder rb) { - SolrQueryRequest req = rb.req; - String rid = req.getParams().get(CommonParams.REQUEST_ID); - if(rid == null || "".equals(rid)) { - rid = generateRid(rb); - ModifiableSolrParams params = new ModifiableSolrParams(req.getParams()); - params.add(CommonParams.REQUEST_ID, rid);//add rid to the request so that shards see it - req.setParams(params); - } + String rid = getRequestId(rb.req); rb.addDebug(rid, "track", CommonParams.REQUEST_ID);//to see it in the response rb.rsp.addToLog(CommonParams.REQUEST_ID, rid); //to see it in the logs of the landing core } + public static String getRequestId(SolrQueryRequest req) { + String rid = req.getParams().get(CommonParams.REQUEST_ID); + if(rid == null || "".equals(rid)) { + rid = generateRid(req); + ModifiableSolrParams params = new ModifiableSolrParams(req.getParams()); + params.add(CommonParams.REQUEST_ID, rid);//add rid to the request so that shards see it + req.setParams(params); + } + return rid; + } + @SuppressForbidden(reason = "Need currentTimeMillis, only used for naming") - private String generateRid(ResponseBuilder rb) { - String hostName = rb.req.getCore().getCoreContainer().getHostName(); - return hostName + "-" + rb.req.getCore().getName() + "-" + System.currentTimeMillis() + "-" + ridCounter.getAndIncrement(); + private static String generateRid(SolrQueryRequest req) { + String hostName = req.getCore().getCoreContainer().getHostName(); + return hostName + "-" + req.getCore().getName() + "-" + System.currentTimeMillis() + "-" + ridCounter.getAndIncrement(); } @Override