Package org.apache.solr.servlet
Class HttpSolrCall
- java.lang.Object
-
- org.apache.solr.servlet.HttpSolrCall
-
- Direct Known Subclasses:
CoordinatorHttpSolrCall
,V2HttpCall
@ThreadSafe public class HttpSolrCall extends Object
This class represents a call made to Solr
-
-
Field Summary
Fields Modifier and Type Field Description protected SolrDispatchFilter.Action
action
protected List<String>
collectionsList
protected SolrConfig
config
protected SolrCore
core
protected CoreContainer
cores
protected String
coreUrl
protected SolrRequestHandler
handler
static String
INTERNAL_REQUEST_COUNT
protected Map<String,Integer>
invalidStates
protected String
origCorename
static String
ORIGINAL_USER_PRINCIPAL_HEADER
protected String
path
protected org.apache.solr.common.params.SolrParams
queryParams
protected javax.servlet.http.HttpServletRequest
req
protected AuthorizationContext.RequestType
requestType
protected javax.servlet.http.HttpServletResponse
response
protected boolean
retry
protected SolrDispatchFilter
solrDispatchFilter
protected SolrQueryRequest
solrReq
-
Constructor Summary
Constructors Constructor Description HttpSolrCall(SolrDispatchFilter solrDispatchFilter, CoreContainer cores, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean retry)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Object
_getHandler()
protected void
addCollectionParamIfNeeded(List<String> collections)
Sets the "collection" parameter on the request to the list of alias-resolved collections for this request.protected void
autoCreateSystemColl(String corename)
SolrDispatchFilter.Action
call()
This method processes the request.protected void
executeCoreRequest(SolrQueryResponse rsp)
protected void
extractHandlerFromURLPath(SolrRequestParsers parser)
Extract handler from the URL path if not set.protected void
extractRemotePath(String collectionName, String origCorename)
List<String>
getCollectionsList()
The collection(s) referenced in this request.List<org.apache.solr.common.util.CommandOperation>
getCommands(boolean validateInput)
SolrCore
getCore()
protected SolrCore
getCoreByCollection(String collectionName, boolean isPreferLeader)
Retrieves a SolrCore instance associated with the specified collection name, with an option to prefer leader replicas.protected String
getCoreOrColName()
String
getPath()
org.apache.solr.common.params.SolrParams
getQueryParams()
protected String
getRemoteCoreUrl(String collectionName, String origCorename)
javax.servlet.http.HttpServletRequest
getReq()
protected QueryResponseWriter
getResponseWriter()
ReturnsQueryResponseWriter
to be used.protected io.opentracing.Span
getSpan()
Get the span for this request.protected org.apache.solr.common.util.ValidatingJsonMap
getSpec()
protected Map<String,org.apache.solr.common.util.JsonSchemaValidator>
getValidators()
protected void
handleAdmin(SolrQueryResponse solrResp)
protected void
handleAdminOrRemoteRequest()
Handle a request whose "type" could not be discerned in advance and may be either "admin" or "remotequery".protected void
init()
protected void
logAndFlushAdminRequest(SolrQueryResponse solrResp)
protected void
populateTracingSpan(io.opentracing.Span span)
protected List<String>
resolveCollectionListOrAlias(String collectionStr)
Resolves the parameter as a potential comma delimited list of collections, and resolves aliases too.protected org.apache.solr.common.cloud.DocCollection
resolveDocCollection(String collectionName)
Resolves the specified collection name to aDocCollection
object.protected void
sendError(int code, String message)
protected void
sendError(Throwable ex)
protected void
sendRemoteQuery()
boolean
shouldAudit()
static boolean
shouldAudit(CoreContainer cores)
static boolean
shouldAudit(CoreContainer cores, AuditEvent.EventType eventType)
boolean
shouldAudit(AuditEvent.EventType eventType)
protected void
writeResponse(SolrQueryResponse solrRsp, QueryResponseWriter responseWriter, Method reqMethod)
-
-
-
Field Detail
-
ORIGINAL_USER_PRINCIPAL_HEADER
public static final String ORIGINAL_USER_PRINCIPAL_HEADER
- See Also:
- Constant Field Values
-
INTERNAL_REQUEST_COUNT
public static final String INTERNAL_REQUEST_COUNT
- See Also:
- Constant Field Values
-
solrDispatchFilter
protected final SolrDispatchFilter solrDispatchFilter
-
cores
protected final CoreContainer cores
-
req
protected final javax.servlet.http.HttpServletRequest req
-
response
protected final javax.servlet.http.HttpServletResponse response
-
retry
protected final boolean retry
-
core
protected SolrCore core
-
solrReq
protected SolrQueryRequest solrReq
-
handler
protected SolrRequestHandler handler
-
queryParams
protected org.apache.solr.common.params.SolrParams queryParams
-
path
protected String path
-
action
protected SolrDispatchFilter.Action action
-
coreUrl
protected String coreUrl
-
config
protected SolrConfig config
-
origCorename
protected String origCorename
-
requestType
protected AuthorizationContext.RequestType requestType
-
-
Constructor Detail
-
HttpSolrCall
public HttpSolrCall(SolrDispatchFilter solrDispatchFilter, CoreContainer cores, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean retry)
-
-
Method Detail
-
getPath
public String getPath()
-
getReq
public javax.servlet.http.HttpServletRequest getReq()
-
getCore
public SolrCore getCore()
-
getQueryParams
public org.apache.solr.common.params.SolrParams getQueryParams()
-
getCollectionsList
public List<String> getCollectionsList()
The collection(s) referenced in this request. Populated ininit()
. Not null.
-
resolveDocCollection
protected org.apache.solr.common.cloud.DocCollection resolveDocCollection(String collectionName)
Resolves the specified collection name to aDocCollection
object. If Solr is not in cloud mode, aSolrException
is thrown. Returns null if the collection name is null or empty. Retrieves theDocCollection
using theZkStateReader
fromCoreContainer
. If the collection is null, updates the state by refreshing aliases and forcing a collection update.
-
autoCreateSystemColl
protected void autoCreateSystemColl(String corename) throws Exception
- Throws:
Exception
-
resolveCollectionListOrAlias
protected List<String> resolveCollectionListOrAlias(String collectionStr)
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
protected void extractHandlerFromURLPath(SolrRequestParsers parser) throws Exception
Extract handler from the URL path if not set.- Throws:
Exception
-
extractRemotePath
protected void extractRemotePath(String collectionName, String origCorename) throws org.apache.zookeeper.KeeperException, InterruptedException, org.apache.solr.common.SolrException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
org.apache.solr.common.SolrException
-
sendRemoteQuery
protected void sendRemoteQuery() throws IOException
- Throws:
IOException
-
call
public SolrDispatchFilter.Action call() throws IOException
This method processes the request.- Throws:
IOException
-
handleAdminOrRemoteRequest
protected void handleAdminOrRemoteRequest() throws IOException
Handle a request whose "type" could not be discerned in advance and may be either "admin" or "remotequery".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:
V2HttpCall
-
getSpan
protected io.opentracing.Span getSpan()
Get the span for this request. Not null.
-
populateTracingSpan
protected void populateTracingSpan(io.opentracing.Span span)
-
getCoreOrColName
protected String getCoreOrColName()
-
shouldAudit
public boolean shouldAudit()
-
shouldAudit
public boolean shouldAudit(AuditEvent.EventType eventType)
-
shouldAudit
public static boolean shouldAudit(CoreContainer cores)
-
shouldAudit
public static boolean shouldAudit(CoreContainer cores, AuditEvent.EventType eventType)
-
sendError
protected void sendError(Throwable ex) throws IOException
- Throws:
IOException
-
sendError
protected void sendError(int code, String message) throws IOException
- Throws:
IOException
-
executeCoreRequest
protected void executeCoreRequest(SolrQueryResponse rsp)
-
logAndFlushAdminRequest
protected void logAndFlushAdminRequest(SolrQueryResponse solrResp) throws IOException
- Throws:
IOException
-
getResponseWriter
protected QueryResponseWriter getResponseWriter()
ReturnsQueryResponseWriter
to be used. WhenCommonParams.WT
not specified in the request or specified value doesn't have correspondingQueryResponseWriter
then, returns the default query response writer Note: This method must not return null
-
handleAdmin
protected void handleAdmin(SolrQueryResponse solrResp)
-
addCollectionParamIfNeeded
protected void addCollectionParamIfNeeded(List<String> collections)
Sets the "collection" parameter on the request to the list of alias-resolved collections for this request. It can be avoided sometimes. Note:HttpShardHandler
processes this param.- See Also:
getCollectionsList()
-
writeResponse
protected void writeResponse(SolrQueryResponse solrRsp, QueryResponseWriter responseWriter, Method reqMethod) throws IOException
- Throws:
IOException
-
getCoreByCollection
protected SolrCore getCoreByCollection(String collectionName, boolean isPreferLeader)
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, String origCorename) throws org.apache.solr.common.SolrException
- Throws:
org.apache.solr.common.SolrException
-
_getHandler
protected Object _getHandler()
-
getCommands
public List<org.apache.solr.common.util.CommandOperation> getCommands(boolean validateInput)
-
getSpec
protected org.apache.solr.common.util.ValidatingJsonMap getSpec()
-
-