|
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.Map;
|
22 | 23 | import java.util.Properties;
|
|
30 | 31 | import org.apache.solr.common.cloud.DocCollection;
|
31 | 32 | import org.apache.solr.common.cloud.Replica;
|
32 | 33 | import org.apache.solr.common.cloud.ZkStateReader;
|
| 34 | +import org.apache.solr.common.params.CommonParams; |
| 35 | +import org.apache.solr.common.util.NamedList; |
33 | 36 | import org.apache.solr.core.CoreContainer;
|
34 | 37 | import org.apache.solr.core.CoreDescriptor;
|
35 | 38 | import org.apache.solr.core.SolrCore;
|
36 | 39 | import org.apache.solr.core.SyntheticSolrCore;
|
37 | 40 | import org.apache.solr.logging.MDCLoggingContext;
|
38 | 41 | import org.apache.solr.request.DelegatingSolrQueryRequest;
|
39 | 42 | import org.apache.solr.request.SolrQueryRequest;
|
| 43 | +import org.apache.solr.response.QueryResponseWriter; |
| 44 | +import org.apache.solr.response.SolrQueryResponse; |
| 45 | +import org.apache.solr.servlet.cache.Method; |
40 | 46 | import org.slf4j.Logger;
|
41 | 47 | import org.slf4j.LoggerFactory;
|
42 | 48 |
|
@@ -67,12 +73,33 @@ public CoordinatorHttpSolrCall(
|
67 | 73 | this.factory = factory;
|
68 | 74 | }
|
69 | 75 |
|
| 76 | + @SuppressWarnings("unchecked") |
| 77 | + @Override |
| 78 | + protected void writeResponse( |
| 79 | + SolrQueryResponse solrRsp, QueryResponseWriter responseWriter, Method reqMethod) |
| 80 | + throws IOException { |
| 81 | + |
| 82 | + // make coordinator mode explicit |
| 83 | + if (solrRsp.getValues().get(CommonParams.DEBUG) != null) { |
| 84 | + final NamedList<Object> debug = |
| 85 | + (NamedList<Object>) solrRsp.getValues().get(CommonParams.DEBUG); |
| 86 | + if (debug.get(CommonParams.TRACK) != null) { |
| 87 | + final NamedList<Object> track = (NamedList<Object>) debug.get(CommonParams.TRACK); |
| 88 | + track.add("requestCoordinatorNode", cores.getHostName()); |
| 89 | + } |
| 90 | + } |
| 91 | + |
| 92 | + super.writeResponse(solrRsp, responseWriter, reqMethod); |
| 93 | + } |
| 94 | + |
70 | 95 | @Override
|
71 | 96 | protected SolrCore getCoreByCollection(String collectionName, boolean isPreferLeader) {
|
| 97 | + if (collectionName == null || collectionName.trim().isEmpty()) { |
| 98 | + return null; |
| 99 | + } |
72 | 100 | this.collectionName = collectionName;
|
73 | 101 | SolrCore core = super.getCoreByCollection(collectionName, isPreferLeader);
|
74 | 102 | if (core != null) return core;
|
75 |
| - if (!path.endsWith("/select")) return null; |
76 | 103 | return getCore(factory, this, collectionName, isPreferLeader);
|
77 | 104 | }
|
78 | 105 |
|
|
0 commit comments