|
17 | 17 |
|
18 | 18 | package org.apache.solr.servlet;
|
19 | 19 |
|
| 20 | +import java.io.IOException; |
20 | 21 | import java.lang.invoke.MethodHandles;
|
21 | 22 | import java.util.List;
|
22 | 23 | import java.util.Map;
|
|
34 | 35 | import org.apache.solr.common.cloud.DocCollection;
|
35 | 36 | import org.apache.solr.common.cloud.Replica;
|
36 | 37 | import org.apache.solr.common.cloud.ZkStateReader;
|
| 38 | +import org.apache.solr.common.params.CommonParams; |
37 | 39 | import org.apache.solr.common.params.SolrParams;
|
| 40 | +import org.apache.solr.common.util.NamedList; |
38 | 41 | import org.apache.solr.common.util.Utils;
|
39 | 42 | import org.apache.solr.core.CoreContainer;
|
40 | 43 | import org.apache.solr.core.CoreDescriptor;
|
|
43 | 46 | import org.apache.solr.request.DelegatingSolrQueryRequest;
|
44 | 47 | import org.apache.solr.request.LocalSolrQueryRequest;
|
45 | 48 | import org.apache.solr.request.SolrQueryRequest;
|
| 49 | +import org.apache.solr.response.QueryResponseWriter; |
46 | 50 | import org.apache.solr.response.SolrQueryResponse;
|
| 51 | +import org.apache.solr.servlet.cache.Method; |
47 | 52 | import org.slf4j.Logger;
|
48 | 53 | import org.slf4j.LoggerFactory;
|
49 | 54 |
|
@@ -74,12 +79,33 @@ public CoordinatorHttpSolrCall(
|
74 | 79 | this.factory = factory;
|
75 | 80 | }
|
76 | 81 |
|
| 82 | + @SuppressWarnings("unchecked") |
| 83 | + @Override |
| 84 | + protected void writeResponse( |
| 85 | + SolrQueryResponse solrRsp, QueryResponseWriter responseWriter, Method reqMethod) |
| 86 | + throws IOException { |
| 87 | + |
| 88 | + // make coordinator mode explicit |
| 89 | + if (solrRsp.getValues().get(CommonParams.DEBUG) != null) { |
| 90 | + final NamedList<Object> debug = |
| 91 | + (NamedList<Object>) solrRsp.getValues().get(CommonParams.DEBUG); |
| 92 | + if (debug.get(CommonParams.TRACK) != null) { |
| 93 | + final NamedList<Object> track = (NamedList<Object>) debug.get(CommonParams.TRACK); |
| 94 | + track.add("requestCoordinatorNode", cores.getHostName()); |
| 95 | + } |
| 96 | + } |
| 97 | + |
| 98 | + super.writeResponse(solrRsp, responseWriter, reqMethod); |
| 99 | + } |
| 100 | + |
77 | 101 | @Override
|
78 | 102 | protected SolrCore getCoreByCollection(String collectionName, boolean isPreferLeader) {
|
| 103 | + if (collectionName == null || collectionName.trim().isEmpty()) { |
| 104 | + return null; |
| 105 | + } |
79 | 106 | this.collectionName = collectionName;
|
80 | 107 | SolrCore core = super.getCoreByCollection(collectionName, isPreferLeader);
|
81 | 108 | if (core != null) return core;
|
82 |
| - if (!path.endsWith("/select")) return null; |
83 | 109 | return getCore(factory, this, collectionName, isPreferLeader);
|
84 | 110 | }
|
85 | 111 |
|
|
0 commit comments