Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog/unreleased/SOLR-18112-SolrDispatchFilterServlet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: SolrDispatchFilter is now SolrServlet; isn't a Filter
type: other
authors:
- name: David Smiley
links:
- name: SOLR-18112
url: https://issues.apache.org/jira/browse/SOLR-18112
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,19 @@
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;
import org.apache.solr.servlet.CoordinatorHttpSolrCall;
import org.apache.solr.servlet.SolrDispatchFilter;
import org.apache.solr.servlet.HttpSolrCall;

public class CoordinatorV2HttpSolrCall extends V2HttpCall {
private String collectionName;
CoordinatorHttpSolrCall.Factory factory;

public CoordinatorV2HttpSolrCall(
CoordinatorHttpSolrCall.Factory factory,
SolrDispatchFilter solrDispatchFilter,
CoreContainer cc,
HttpServletRequest request,
HttpServletResponse response,
boolean retry) {
super(solrDispatchFilter, cc, request, response, retry);
super(cc, request, response, retry);
this.factory = factory;
}

Expand All @@ -51,7 +50,7 @@ protected SolrCore getCoreByCollection(String collectionName, boolean isPreferLe
@Override
protected void init() throws Exception {
super.init();
if (action == SolrDispatchFilter.Action.PROCESS && core != null) {
if (action == HttpSolrCall.Action.PROCESS && core != null) {
solrReq = CoordinatorHttpSolrCall.wrappedReq(solrReq, collectionName, this);
}
}
Expand Down
17 changes: 6 additions & 11 deletions solr/core/src/java/org/apache/solr/api/V2HttpCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
package org.apache.solr.api;

import static org.apache.solr.common.cloud.ZkStateReader.COLLECTION_PROP;
import static org.apache.solr.servlet.SolrDispatchFilter.Action.ADMIN;
import static org.apache.solr.servlet.SolrDispatchFilter.Action.ADMIN_OR_REMOTEPROXY;
import static org.apache.solr.servlet.SolrDispatchFilter.Action.PROCESS;
import static org.apache.solr.servlet.SolrDispatchFilter.Action.REMOTEPROXY;
import static org.apache.solr.servlet.HttpSolrCall.Action.ADMIN;
import static org.apache.solr.servlet.HttpSolrCall.Action.ADMIN_OR_REMOTEPROXY;
import static org.apache.solr.servlet.HttpSolrCall.Action.PROCESS;
import static org.apache.solr.servlet.HttpSolrCall.Action.REMOTEPROXY;

import io.opentelemetry.api.trace.Span;
import jakarta.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -56,7 +56,6 @@
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.security.AuthorizationContext;
import org.apache.solr.servlet.HttpSolrCall;
import org.apache.solr.servlet.SolrDispatchFilter;
import org.apache.solr.servlet.SolrRequestParsers;
import org.apache.solr.servlet.cache.Method;
import org.apache.solr.util.tracing.TraceUtils;
Expand All @@ -78,12 +77,8 @@ public class V2HttpCall extends HttpSolrCall {
static final Set<String> knownPrefixes = Set.of("cluster", "node", "collections", "cores", "c");

public V2HttpCall(
SolrDispatchFilter solrDispatchFilter,
CoreContainer cc,
HttpServletRequest request,
HttpServletResponse response,
boolean retry) {
super(solrDispatchFilter, cc, request, response, retry);
CoreContainer cc, HttpServletRequest request, HttpServletResponse response, boolean retry) {
super(cc, request, response, retry);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.solr.cli;

import static org.apache.solr.servlet.SolrDispatchFilter.SOLR_INSTALL_DIR_ATTRIBUTE;
import static org.apache.solr.servlet.CoreContainerProvider.SOLR_INSTALL_DIR;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
Expand Down Expand Up @@ -76,7 +76,7 @@ public SolrProcessManager() {
ph.pid(), parsePortFromProcess(ph).orElseThrow(), isProcessSsl(ph))));
portProcessMap =
pidProcessMap.values().stream().collect(Collectors.toUnmodifiableMap(p -> p.port, p -> p));
String solrInstallDir = EnvUtils.getProperty(SOLR_INSTALL_DIR_ATTRIBUTE);
String solrInstallDir = EnvUtils.getProperty(SOLR_INSTALL_DIR);
pidDir =
Path.of(
EnvUtils.getProperty(
Expand Down
6 changes: 3 additions & 3 deletions solr/core/src/java/org/apache/solr/cloud/SolrZkServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.concurrent.atomic.AtomicReference;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.util.EnvUtils;
import org.apache.solr.servlet.SolrDispatchFilter;
import org.apache.solr.servlet.CoreContainerProvider;
import org.apache.solr.util.AddressUtils;
import org.apache.zookeeper.server.ServerConfig;
import org.apache.zookeeper.server.ZooKeeperServerMain;
Expand Down Expand Up @@ -104,12 +104,12 @@ public void parseConfig() {
var zooCfgPath = Path.of(confHome).resolve("zoo.cfg");
if (!Files.exists(zooCfgPath)) {
log.info("Zookeeper configuration not found in {}, using built-in default", confHome);
String solrInstallDir = System.getProperty(SolrDispatchFilter.SOLR_INSTALL_DIR_ATTRIBUTE);
String solrInstallDir = System.getProperty(CoreContainerProvider.SOLR_INSTALL_DIR);
if (solrInstallDir == null) {
throw new SolrException(
SolrException.ErrorCode.SERVER_ERROR,
"Could not find default zoo.cfg file due to missing "
+ SolrDispatchFilter.SOLR_INSTALL_DIR_ATTRIBUTE);
+ CoreContainerProvider.SOLR_INSTALL_DIR);
}
zooCfgPath = Path.of(solrInstallDir).resolve("server").resolve("solr").resolve("zoo.cfg");
}
Expand Down
12 changes: 6 additions & 6 deletions solr/core/src/java/org/apache/solr/core/ConfigSetService.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import org.apache.solr.handler.admin.ConfigSetsHandler;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.IndexSchemaFactory;
import org.apache.solr.servlet.SolrDispatchFilter;
import org.apache.solr.servlet.CoreContainerProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -48,6 +48,7 @@ public abstract class ConfigSetService {
public static final String UPLOAD_FILENAME_EXCLUDE_REGEX = "^\\..*$";
public static final Pattern UPLOAD_FILENAME_EXCLUDE_PATTERN =
Pattern.compile(UPLOAD_FILENAME_EXCLUDE_REGEX);
public static final String SOLR_CONFIGSET_DEFAULT_CONFDIR = "solr.configset.default.confdir";

public static final String FORBIDDEN_FILE_TYPES_PROP = "solr.configset.forbidden.file.types";
public static final Set<String> DEFAULT_FORBIDDEN_FILE_TYPES =
Expand Down Expand Up @@ -136,7 +137,7 @@ private void bootstrapDefaultConf() throws IOException {
log.warn(
"The _default configset could not be uploaded. Please provide 'solr.configset.default.confdir' parameter that points to a configset {} {}",
"intended to be the default. Current 'solr.configset.default.confdir' value:",
System.getProperty(SolrDispatchFilter.SOLR_CONFIGSET_DEFAULT_CONFDIR_ATTRIBUTE));
System.getProperty(SOLR_CONFIGSET_DEFAULT_CONFDIR));
} else {
this.uploadConfig(ConfigSetsHandler.DEFAULT_CONFIGSET_NAME, configDirPath);
}
Expand All @@ -161,19 +162,18 @@ private void bootstrapConfDir(String confDir) throws IOException {
* to the sysprop "solr.install.dir". Returns null if not found anywhere.
*
* @lucene.internal
* @see SolrDispatchFilter#SOLR_CONFIGSET_DEFAULT_CONFDIR_ATTRIBUTE
* @see ConfigSetService#SOLR_CONFIGSET_DEFAULT_CONFDIR
*/
public static Path getDefaultConfigDirPath() {
String confDir =
System.getProperty(SolrDispatchFilter.SOLR_CONFIGSET_DEFAULT_CONFDIR_ATTRIBUTE);
String confDir = System.getProperty(SOLR_CONFIGSET_DEFAULT_CONFDIR);
if (confDir != null) {
Path path = Path.of(confDir);
if (Files.exists(path)) {
return path;
}
}

String installDir = System.getProperty(SolrDispatchFilter.SOLR_INSTALL_DIR_ATTRIBUTE);
String installDir = System.getProperty(CoreContainerProvider.SOLR_INSTALL_DIR);
if (installDir != null) {
Path subPath = Path.of("server", "solr", "configsets", "_default", "conf");
Path path = Path.of(installDir).resolve(subPath);
Expand Down
8 changes: 4 additions & 4 deletions solr/core/src/java/org/apache/solr/core/NodeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import org.apache.solr.common.util.StrUtils;
import org.apache.solr.logging.LogWatcherConfig;
import org.apache.solr.search.CacheConfig;
import org.apache.solr.servlet.SolrDispatchFilter;
import org.apache.solr.servlet.CoreContainerProvider;
import org.apache.solr.update.UpdateShardHandlerConfig;
import org.apache.solr.util.ModuleUtils;
import org.slf4j.Logger;
Expand Down Expand Up @@ -294,7 +294,7 @@ public Path getSolrDataHome() {
* @return path to install dir or null if solr.install.dir not set.
*/
public static Path getSolrInstallDir() {
String prop = System.getProperty(SolrDispatchFilter.SOLR_INSTALL_DIR_ATTRIBUTE);
String prop = System.getProperty(CoreContainerProvider.SOLR_INSTALL_DIR);
if (prop == null || prop.isBlank()) {
log.debug("solr.install.dir property not initialized.");
return null;
Expand Down Expand Up @@ -451,7 +451,7 @@ private void setupSharedLib() {
if (solrInstallDir == null) {
log.warn(
"Unable to add $SOLR_HOME/lib for shared lib since {} was not set.",
SolrDispatchFilter.SOLR_INSTALL_DIR_ATTRIBUTE);
CoreContainerProvider.SOLR_INSTALL_DIR);
} else {
// Always add $SOLR_TIP/lib to the shared resource loader
libDirs.add(solrInstallDir.resolve("lib").toAbsolutePath().normalize().toString());
Expand Down Expand Up @@ -524,7 +524,7 @@ public static void initModules(SolrResourceLoader loader, String modules) {
"Unable to setup modules "
+ moduleNames
+ " because "
+ SolrDispatchFilter.SOLR_INSTALL_DIR_ATTRIBUTE
+ CoreContainerProvider.SOLR_INSTALL_DIR
+ " was not set.");
}
return;
Expand Down
15 changes: 7 additions & 8 deletions solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import org.apache.solr.common.util.Utils;
import org.apache.solr.logging.LogWatcherConfig;
import org.apache.solr.search.CacheConfig;
import org.apache.solr.servlet.SolrDispatchFilter;
import org.apache.solr.servlet.CoreContainerProvider;
import org.apache.solr.update.UpdateShardHandlerConfig;
import org.apache.solr.util.DOMConfigNode;
import org.apache.solr.util.DataConfigNode;
Expand Down Expand Up @@ -77,9 +77,8 @@ public class SolrXmlConfig {
* wrapping the original Properties, with the 'zkHost' value set based on the value of the
* corresponding System property (if set)
*
* <p>In theory we only need this logic once, ideally in SolrDispatchFilter, but we put it here to
* re-use redundantly because of how much surface area our API has for various tests to poke at
* us.
* <p>In theory we only need this logic once, ideally in SolrServlet, but we put it here to re-use
* redundantly because of how much surface area our API has for various tests to poke at us.
*/
public static Properties wrapAndSetZkHostFromSysPropIfNeeded(final Properties props) {
if (null != props && StrUtils.isNotNullOrEmpty(props.getProperty(ZK_HOST))) {
Expand All @@ -104,8 +103,8 @@ public static NodeConfig fromConfig(
// *directly* check the system
// property if it's not specified.
//
// (checking the sys prop here is really just for tests that by-pass SolrDispatchFilter. In
// non-test situations, SolrDispatchFilter will check the system property if needed in order to
// (checking the sys prop here is really just for tests that by-pass SolrServlet. In
// non-test situations, SolrServlet will check the system property if needed in order to
// try and load solr.xml from ZK, and should have put the sys prop value in the node properties
// for us)
final String defaultZkHost =
Expand Down Expand Up @@ -180,12 +179,12 @@ public static NodeConfig fromFile(Path solrHome, Path configFile, Properties sub
"solr.xml does not exist in " + configFile.getParent() + " cannot start Solr");
}
log.info("solr.xml not found in SOLR_HOME, using built-in default");
String solrInstallDir = System.getProperty(SolrDispatchFilter.SOLR_INSTALL_DIR_ATTRIBUTE);
String solrInstallDir = System.getProperty(CoreContainerProvider.SOLR_INSTALL_DIR);
if (solrInstallDir == null) {
throw new SolrException(
SolrException.ErrorCode.SERVER_ERROR,
"Could not find default solr.xml file due to missing "
+ SolrDispatchFilter.SOLR_INSTALL_DIR_ATTRIBUTE);
+ CoreContainerProvider.SOLR_INSTALL_DIR);
}
configFile = Path.of(solrInstallDir).resolve("server").resolve("solr").resolve("solr.xml");
}
Expand Down
13 changes: 6 additions & 7 deletions solr/core/src/java/org/apache/solr/request/SolrRequestInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.apache.solr.handler.component.ResponseBuilder;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.search.QueryLimits;
import org.apache.solr.servlet.SolrDispatchFilter;
import org.apache.solr.servlet.HttpSolrCall;
import org.apache.solr.util.TimeZoneUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -54,7 +54,7 @@ public class SolrRequestInfo {
private TimeZone tz;
private ResponseBuilder rb;
private List<AutoCloseable> closeHooks;
private SolrDispatchFilter.Action action;
private HttpSolrCall.Action action;
private boolean useServerToken = false;
private Principal principal;

Expand Down Expand Up @@ -154,8 +154,7 @@ public SolrRequestInfo(SolrQueryRequest req, SolrQueryResponse rsp) {
this.principal = req != null ? req.getUserPrincipal() : null;
}

public SolrRequestInfo(
SolrQueryRequest req, SolrQueryResponse rsp, SolrDispatchFilter.Action action) {
public SolrRequestInfo(SolrQueryRequest req, SolrQueryResponse rsp, HttpSolrCall.Action action) {
this(req, rsp);
this.setAction(action);
}
Expand All @@ -166,7 +165,7 @@ public SolrRequestInfo(HttpServletRequest httpReq, SolrQueryResponse rsp) {
}

public SolrRequestInfo(
HttpServletRequest httpReq, SolrQueryResponse rsp, SolrDispatchFilter.Action action) {
HttpServletRequest httpReq, SolrQueryResponse rsp, HttpSolrCall.Action action) {
this(httpReq, rsp);
this.action = action;
}
Expand Down Expand Up @@ -259,11 +258,11 @@ public static QueryLimits getQueryLimits(SolrQueryRequest request, SolrQueryResp
request.getContext().computeIfAbsent(LIMITS_KEY, (k) -> new QueryLimits(request, response));
}

public SolrDispatchFilter.Action getAction() {
public HttpSolrCall.Action getAction() {
return action;
}

public void setAction(SolrDispatchFilter.Action action) {
public void setAction(HttpSolrCall.Action action) {
this.action = action;
}

Expand Down
4 changes: 2 additions & 2 deletions solr/core/src/java/org/apache/solr/rest/BaseSolrResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ protected BaseSolrResource() {
}

/**
* Pulls the SolrQueryRequest constructed in SolrDispatchFilter from the SolrRequestInfo thread
* local, then gets the SolrCore and IndexSchema and sets up the response. writer.
* Pulls the SolrQueryRequest constructed in SolrServlet from the SolrRequestInfo thread local,
* then gets the SolrCore and IndexSchema and sets up the response. writer.
*/
public void doInit(SolrQueryRequest solrRequest, SolrQueryResponse solrResponse) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,11 @@ public class CoordinatorHttpSolrCall extends HttpSolrCall {

public CoordinatorHttpSolrCall(
Factory factory,
SolrDispatchFilter solrDispatchFilter,
CoreContainer cores,
HttpServletRequest request,
HttpServletResponse response,
boolean retry) {
super(solrDispatchFilter, cores, request, response, retry);
super(cores, request, response, retry);
this.factory = factory;
}

Expand Down Expand Up @@ -150,7 +149,7 @@ public static String getSyntheticCoreNameFromConfig(String configName) {
@Override
protected void init() throws Exception {
super.init();
if (action == SolrDispatchFilter.Action.PROCESS && core != null) {
if (action == HttpSolrCall.Action.PROCESS && core != null) {
solrReq = wrappedReq(solrReq, collectionName, this);
}
}
Expand Down Expand Up @@ -199,24 +198,23 @@ private static void setMdcLoggingContext(String collectionName) {
}

// The factory that creates an instance of HttpSolrCall
public static class Factory implements SolrDispatchFilter.HttpSolrCallFactory {
public static class Factory implements SolrServlet.HttpSolrCallFactory {
private final Map<String, String> collectionVsCoreNameMapping = new ConcurrentHashMap<>();

@Override
public HttpSolrCall createInstance(
SolrDispatchFilter filter,
String path,
CoreContainer cores,
HttpServletRequest request,
HttpServletResponse response,
boolean retry) {
if ((path.startsWith("/____v2/") || path.equals("/____v2"))) {
return new CoordinatorV2HttpSolrCall(this, filter, cores, request, response, retry);
return new CoordinatorV2HttpSolrCall(this, cores, request, response, retry);
} else if (path.startsWith("/" + SYNTHETIC_COLL_PREFIX)) {
return SolrDispatchFilter.HttpSolrCallFactory.super.createInstance(
filter, path, cores, request, response, retry);
return SolrServlet.HttpSolrCallFactory.super.createInstance(
path, cores, request, response, retry);
} else {
return new CoordinatorHttpSolrCall(this, filter, cores, request, response, retry);
return new CoordinatorHttpSolrCall(this, cores, request, response, retry);
}
}
}
Expand Down
Loading
Loading