Skip to content

Commit 554c0de

Browse files
committed
[SOLR-17334] Enable coordinator nodes to handle requests outside of /select
- Enables coordinator requests for handlers outside of `/select` - Fixes access to the root resource on the coordinator node - Adds debugging of the current `requestCoordinatorNode` to pre-existing debug output
1 parent b9862aa commit 554c0de

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

solr/core/src/java/org/apache/solr/servlet/CoordinatorHttpSolrCall.java

+27-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.apache.solr.servlet;
1919

20+
import java.io.IOException;
2021
import java.lang.invoke.MethodHandles;
2122
import java.util.List;
2223
import java.util.Map;
@@ -34,7 +35,9 @@
3435
import org.apache.solr.common.cloud.DocCollection;
3536
import org.apache.solr.common.cloud.Replica;
3637
import org.apache.solr.common.cloud.ZkStateReader;
38+
import org.apache.solr.common.params.CommonParams;
3739
import org.apache.solr.common.params.SolrParams;
40+
import org.apache.solr.common.util.NamedList;
3841
import org.apache.solr.common.util.Utils;
3942
import org.apache.solr.core.CoreContainer;
4043
import org.apache.solr.core.CoreDescriptor;
@@ -43,7 +46,9 @@
4346
import org.apache.solr.request.DelegatingSolrQueryRequest;
4447
import org.apache.solr.request.LocalSolrQueryRequest;
4548
import org.apache.solr.request.SolrQueryRequest;
49+
import org.apache.solr.response.QueryResponseWriter;
4650
import org.apache.solr.response.SolrQueryResponse;
51+
import org.apache.solr.servlet.cache.Method;
4752
import org.slf4j.Logger;
4853
import org.slf4j.LoggerFactory;
4954

@@ -74,12 +79,33 @@ public CoordinatorHttpSolrCall(
7479
this.factory = factory;
7580
}
7681

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+
77101
@Override
78102
protected SolrCore getCoreByCollection(String collectionName, boolean isPreferLeader) {
103+
if (collectionName == null || collectionName.trim().isEmpty()) {
104+
return null;
105+
}
79106
this.collectionName = collectionName;
80107
SolrCore core = super.getCoreByCollection(collectionName, isPreferLeader);
81108
if (core != null) return core;
82-
if (!path.endsWith("/select")) return null;
83109
return getCore(factory, this, collectionName, isPreferLeader);
84110
}
85111

0 commit comments

Comments
 (0)