Skip to content

Commit

Permalink
[apache#2527] SOLR-17334 Re-implement changes compatible to Solr 9.7+
Browse files Browse the repository at this point in the history
  • Loading branch information
tboeghk committed Sep 11, 2024
1 parent 1484f6f commit 88b2027
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.solr.servlet;

import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.Map;
import java.util.Properties;
Expand All @@ -30,13 +31,18 @@
import org.apache.solr.common.cloud.DocCollection;
import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SyntheticSolrCore;
import org.apache.solr.logging.MDCLoggingContext;
import org.apache.solr.request.DelegatingSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.QueryResponseWriter;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.servlet.cache.Method;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -67,12 +73,33 @@ public CoordinatorHttpSolrCall(
this.factory = factory;
}

@SuppressWarnings("unchecked")
@Override
protected void writeResponse(
SolrQueryResponse solrRsp, QueryResponseWriter responseWriter, Method reqMethod)
throws IOException {

// make coordinator mode explicit
if (solrRsp.getValues().get(CommonParams.DEBUG) != null) {
final NamedList<Object> debug =
(NamedList<Object>) solrRsp.getValues().get(CommonParams.DEBUG);
if (debug.get(CommonParams.TRACK) != null) {
final NamedList<Object> track = (NamedList<Object>) debug.get(CommonParams.TRACK);
track.add("requestCoordinatorNode", cores.getHostName());
}
}

super.writeResponse(solrRsp, responseWriter, reqMethod);
}

@Override
protected SolrCore getCoreByCollection(String collectionName, boolean isPreferLeader) {
if (collectionName == null || collectionName.trim().isEmpty()) {
return null;
}
this.collectionName = collectionName;
SolrCore core = super.getCoreByCollection(collectionName, isPreferLeader);
if (core != null) return core;
if (!path.endsWith("/select")) return null;
return getCore(factory, this, collectionName, isPreferLeader);
}

Expand Down

0 comments on commit 88b2027

Please sign in to comment.