Package org.apache.solr.servlet
Class HttpSolrCall
java.lang.Object
org.apache.solr.servlet.HttpSolrCall
- Direct Known Subclasses:
CoordinatorHttpSolrCall,V2HttpCall
This class represents a call made to Solr
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SolrDispatchFilter.Actionprotected SolrConfigprotected SolrCoreprotected final CoreContainerprotected Stringprotected SolrRequestHandlerstatic final Stringprotected Stringprotected Stringprotected org.apache.solr.common.params.SolrParamsprotected final jakarta.servlet.http.HttpServletRequestprotected AuthorizationContext.RequestTypeprotected final jakarta.servlet.http.HttpServletResponseprotected final booleanprotected final SolrDispatchFilterprotected SolrQueryRequest -
Constructor Summary
ConstructorsConstructorDescriptionHttpSolrCall(SolrDispatchFilter solrDispatchFilter, CoreContainer cores, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, boolean retry) -
Method Summary
Modifier and TypeMethodDescriptionprotected Objectprotected voidaddCollectionParamIfNeeded(List<String> collections) Sets the "collection" parameter on the request to the list of alias-resolved collections for this request.call()This method processes the request.protected voidprotected voidExtract handler from the URL path if not set.protected voidextractRemotePath(String collectionName) The collection(s) referenced in this request.List<org.apache.solr.common.util.CommandOperation> getCommands(boolean validateInput) getCore()protected SolrCoregetCoreByCollection(String collectionName, boolean isPreferLeader) Retrieves a SolrCore instance associated with the specified collection name, with an option to prefer leader replicas.protected StringgetPath()org.apache.solr.common.params.SolrParamsprotected StringgetRemoteCoreUrl(String collectionName) jakarta.servlet.http.HttpServletRequestgetReq()WARNING: This method returns a non-nullHttpServletRequest, but calling certain methods on it — such asServletRequest.getAttribute(String)— may throwNullPointerExceptionif accessed outside the original servlet thread (e.g., in asynchronous tasks).protected QueryResponseWriterReturnsQueryResponseWriterto be used.io.opentelemetry.api.trace.SpangetSpan()Get the Span for this request.protected org.apache.solr.common.util.ValidatingJsonMapgetSpec()Gets the client (user-agent) SolrJ version, or null if isn't SolrJ.protected voidhandleAdmin(SolrQueryResponse solrResp) protected voidHandle a request whose "type" could not be discerned in advance and may be either "admin" or "remoteproxy".protected voidinit()protected voidlogAndFlushAdminRequest(SolrQueryResponse solrResp) protected voidnormalizeAndSetPath(String unnormalizedPath) protected voidpopulateTracingSpan(io.opentelemetry.api.trace.Span span) resolveCollectionListOrAlias(String collectionStr) Resolves the parameter as a potential comma delimited list of collections, and resolves aliases too.protected org.apache.solr.common.cloud.DocCollectionresolveDocCollection(String collectionName) Resolves the specified collection name to aDocCollectionobject.protected voidprotected voidprotected voidbooleanstatic booleanshouldAudit(CoreContainer cores) static booleanshouldAudit(CoreContainer cores, AuditEvent.EventType eventType) booleanshouldAudit(AuditEvent.EventType eventType) protected voidwriteResponse(SolrQueryResponse solrRsp, QueryResponseWriter responseWriter, Method reqMethod)
-
Field Details
-
INTERNAL_REQUEST_COUNT
- See Also:
-
solrDispatchFilter
-
cores
-
req
protected final jakarta.servlet.http.HttpServletRequest req -
response
protected final jakarta.servlet.http.HttpServletResponse response -
retry
protected final boolean retry -
core
-
solrReq
-
handler
-
queryParams
protected org.apache.solr.common.params.SolrParams queryParams -
path
-
action
-
coreUrl
-
config
-
invalidStates
-
origCorename
-
collectionsList
-
requestType
-
-
Constructor Details
-
HttpSolrCall
public HttpSolrCall(SolrDispatchFilter solrDispatchFilter, CoreContainer cores, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, boolean retry)
-
-
Method Details
-
normalizeAndSetPath
-
getPath
-
getReq
public jakarta.servlet.http.HttpServletRequest getReq()WARNING: This method returns a non-nullHttpServletRequest, but calling certain methods on it — such asServletRequest.getAttribute(String)— may throwNullPointerExceptionif accessed outside the original servlet thread (e.g., in asynchronous tasks).Always cache required request data early during request handling if it needs to be accessed later.
-
getCore
-
getQueryParams
public org.apache.solr.common.params.SolrParams getQueryParams() -
getCollectionsList
The collection(s) referenced in this request. Populated ininit(). Not null. -
init
- Throws:
Exception
-
resolveDocCollection
Resolves the specified collection name to aDocCollectionobject. If Solr is not in cloud mode, aSolrExceptionis thrown. Returns null if the collection name is null or empty. Retrieves theDocCollectionusing theZkStateReaderfromCoreContainer. If the collection is null, updates the state by refreshing aliases and forcing a collection update. -
resolveCollectionListOrAlias
Resolves the parameter as a potential comma delimited list of collections, and resolves aliases too. One level of aliases pointing to another alias is supported. De-duplicates and retains the order.getCollectionsList() -
extractHandlerFromURLPath
Extract handler from the URL path if not set.- Throws:
Exception
-
extractRemotePath
protected void extractRemotePath(String collectionName) throws org.apache.zookeeper.KeeperException, InterruptedException, org.apache.solr.common.SolrException - Throws:
org.apache.zookeeper.KeeperExceptionInterruptedExceptionorg.apache.solr.common.SolrException
-
call
This method processes the request.- Throws:
IOException
-
handleAdminOrRemoteRequest
Handle a request whose "type" could not be discerned in advance and may be either "admin" or "remoteproxy".Some implementations (such as
V2HttpCall) may find it difficult to differentiate all request types in advance. This method serves as a hook; allowing those implementations to handle these cases gracefully.- Throws:
IOException- See Also:
-
getSpan
public io.opentelemetry.api.trace.Span getSpan()Get the Span for this request. Not null. -
populateTracingSpan
protected void populateTracingSpan(io.opentelemetry.api.trace.Span span) -
getCoreOrColName
-
shouldAudit
public boolean shouldAudit() -
shouldAudit
-
shouldAudit
-
shouldAudit
-
sendRemoteProxy
- Throws:
IOException
-
sendError
- Throws:
IOException
-
sendError
- Throws:
IOException
-
executeCoreRequest
-
logAndFlushAdminRequest
- Throws:
IOException
-
getResponseWriter
ReturnsQueryResponseWriterto be used. WhenCommonParams.WTnot specified in the request or specified value doesn't have correspondingQueryResponseWriterthen, returns the default query response writer Note: This method must not return null -
handleAdmin
-
addCollectionParamIfNeeded
Sets the "collection" parameter on the request to the list of alias-resolved collections for this request. It can be avoided sometimes. Note:HttpShardHandlerprocesses this param.- See Also:
-
writeResponse
protected void writeResponse(SolrQueryResponse solrRsp, QueryResponseWriter responseWriter, Method reqMethod) throws IOException - Throws:
IOException
-
getCoreByCollection
Retrieves a SolrCore instance associated with the specified collection name, with an option to prefer leader replicas. Makes a call toresolveDocCollection(java.lang.String)which make an attempt to force update collection if it is not found in local cluster state -
getRemoteCoreUrl
protected String getRemoteCoreUrl(String collectionName) throws org.apache.solr.common.SolrException - Throws:
org.apache.solr.common.SolrException
-
_getHandler
-
getUserAgentSolrVersion
Gets the client (user-agent) SolrJ version, or null if isn't SolrJ. Note that older SolrJ clients prior to 9.9 present themselves as 1.0 or 2.0. -
getCommands
-
getSpec
protected org.apache.solr.common.util.ValidatingJsonMap getSpec() -
getValidators
-