Package org.apache.solr.handler
Class RequestHandlerBase
- java.lang.Object
-
- org.apache.solr.handler.RequestHandlerBase
-
- All Implemented Interfaces:
AutoCloseable
,ApiSupport
,SolrInfoBean
,NestedRequestHandler
,SolrMetricProducer
,SolrRequestHandler
,PermissionNameProvider
- Direct Known Subclasses:
AnalysisRequestHandlerBase
,BlobHandler
,CollectionsHandler
,ConfigSetsHandler
,ContentStreamHandlerBase
,CoreAdminHandler
,DumpRequestHandler
,FileFloatSource.ReloadCacheRequestHandler
,GraphHandler
,HealthCheckHandler
,InfoHandler
,LoggingHandler
,LukeRequestHandler
,MetricsCollectorHandler
,MetricsHandler
,MoreLikeThisHandler
,NotFoundRequestHandler
,PingRequestHandler
,PluginInfoHandler
,PropertiesRequestHandler
,PublicKeyHandler
,ReplicationHandler
,SchemaHandler
,SearchHandler
,SecurityConfHandler
,SegmentsInfoRequestHandler
,ShowFileRequestHandler
,SolrConfigHandler
,SolrInfoMBeanHandler
,StreamHandler
,SystemInfoHandler
,TaggerRequestHandler
,TaskManagementHandler
,ThreadDumpHandler
,ZookeeperInfoHandler
,ZookeeperStatusHandler
public abstract class RequestHandlerBase extends Object implements SolrRequestHandler, SolrInfoBean, NestedRequestHandler, ApiSupport, PermissionNameProvider
Base class for all request handlers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RequestHandlerBase.HandlerMetrics
Metrics for this handler.-
Nested classes/interfaces inherited from interface org.apache.solr.security.PermissionNameProvider
PermissionNameProvider.Name
-
Nested classes/interfaces inherited from interface org.apache.solr.core.SolrInfoBean
SolrInfoBean.Category, SolrInfoBean.Group
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
aggregateNodeLevelMetricsEnabled
protected org.apache.solr.common.params.SolrParams
appends
protected org.apache.solr.common.params.SolrParams
defaults
protected boolean
httpCaching
protected org.apache.solr.common.util.NamedList<?>
initArgs
protected org.apache.solr.common.params.SolrParams
invariants
protected RequestHandlerBase.HandlerMetrics
metrics
protected SolrMetricsContext
solrMetricsContext
-
Fields inherited from interface org.apache.solr.security.PermissionNameProvider
ANY, NULL, values
-
Fields inherited from interface org.apache.solr.request.SolrRequestHandler
TYPE
-
-
Constructor Summary
Constructors Constructor Description RequestHandlerBase()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Collection<Api>
getApis()
Returns any (non-JAX-RS annotated) APIs associated with this request handler.SolrInfoBean.Category
getCategory()
Category of this componentabstract String
getDescription()
Simple one or two line descriptionorg.apache.solr.common.util.NamedList<?>
getInitArgs()
RequestHandlerBase.HandlerMetrics
getMetricsForThisRequest(SolrQueryRequest req)
The metrics to be used for this request.String
getName()
Simple common usage name, e.g.PluginInfo
getPluginInfo()
static SolrRequestHandler
getRequestHandler(String handlerName, PluginBag<SolrRequestHandler> reqHandlers)
Get the request handler registered to a given name.SolrMetricsContext
getSolrMetricsContext()
Implementations should return the context used inSolrMetricProducer.initializeMetrics(SolrMetricsContext, String)
to ensure proper cleanup of metrics at the end of the life-cycle of this component.static org.apache.solr.common.params.SolrParams
getSolrParamsFromNamedList(org.apache.solr.common.util.NamedList<?> args, String key)
SolrRequestHandler
getSubHandler(String subPath)
Return a RequestHandler to handle a subpath from the path this handler is registered.void
handleRequest(SolrQueryRequest req, SolrQueryResponse rsp)
Handles a query request, this method must be thread safe.abstract void
handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp)
void
init(org.apache.solr.common.util.NamedList<?> args)
Initializes theSolrRequestHandler
by creating threeSolrParams
named.void
initializeMetrics(SolrMetricsContext parentContext, String scope)
Initialize metrics specific to this producer.static boolean
isInternalShardRequest(SolrQueryRequest req)
Checks whether the given request is an internal request to a shard.static Exception
normalizeReceivedException(SolrQueryRequest req, Exception e)
static void
processErrorMetricsOnException(Exception e, RequestHandlerBase.HandlerMetrics metrics)
void
setPluginInfo(PluginInfo pluginInfo)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.solr.api.ApiSupport
getJerseyResources, registerV1, registerV2
-
Methods inherited from interface org.apache.solr.security.PermissionNameProvider
getPermissionName
-
Methods inherited from interface org.apache.solr.metrics.SolrMetricProducer
close
-
-
-
-
Field Detail
-
initArgs
protected org.apache.solr.common.util.NamedList<?> initArgs
-
defaults
protected org.apache.solr.common.params.SolrParams defaults
-
appends
protected org.apache.solr.common.params.SolrParams appends
-
invariants
protected org.apache.solr.common.params.SolrParams invariants
-
httpCaching
protected boolean httpCaching
-
aggregateNodeLevelMetricsEnabled
protected boolean aggregateNodeLevelMetricsEnabled
-
solrMetricsContext
protected SolrMetricsContext solrMetricsContext
-
metrics
protected RequestHandlerBase.HandlerMetrics metrics
-
-
Method Detail
-
init
public void init(org.apache.solr.common.util.NamedList<?> args)
Initializes theSolrRequestHandler
by creating threeSolrParams
named.table of parameters Name Description defaults Contains all of the named arguments contained within the list element named "defaults". appends Contains all of the named arguments contained within the list element named "appends". invariants Contains all of the named arguments contained within the list element named "invariants". Example:
<lst name="defaults"> <str name="echoParams">explicit</str> <str name="qf">text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0</str> <str name="mm">2<-1 5<-2 6<90%</str> <str name="bq">incubationdate_dt:[* TO NOW/DAY-1MONTH]^2.2</str> </lst> <lst name="appends"> <str name="fq">inStock:true</str> </lst> <lst name="invariants"> <str name="facet.field">cat</str> <str name="facet.field">manu_exact</str> <str name="facet.query">price:[* TO 500]</str> <str name="facet.query">price:[500 TO *]</str> </lst>
- Specified by:
init
in interfaceSolrRequestHandler
- Parameters:
args
- TheNamedList
to initialize from- See Also:
handleRequest(org.apache.solr.request.SolrQueryRequest, org.apache.solr.response.SolrQueryResponse)
,handleRequestBody(org.apache.solr.request.SolrQueryRequest, org.apache.solr.response.SolrQueryResponse)
,SolrPluginUtils.setDefaults(org.apache.solr.request.SolrQueryRequest, org.apache.solr.common.params.SolrParams, org.apache.solr.common.params.SolrParams, org.apache.solr.common.params.SolrParams)
,See also the example solrconfig.xml located in the Solr codebase (example/solr/conf).
-
getSolrMetricsContext
public SolrMetricsContext getSolrMetricsContext()
Description copied from interface:SolrMetricProducer
Implementations should return the context used inSolrMetricProducer.initializeMetrics(SolrMetricsContext, String)
to ensure proper cleanup of metrics at the end of the life-cycle of this component. This should be the child context if one was created, or null if the parent context was used.- Specified by:
getSolrMetricsContext
in interfaceSolrMetricProducer
-
initializeMetrics
public void initializeMetrics(SolrMetricsContext parentContext, String scope)
Description copied from interface:SolrMetricProducer
Initialize metrics specific to this producer.- Specified by:
initializeMetrics
in interfaceSolrMetricProducer
- Parameters:
parentContext
- parent metrics context. If this component has the same life-cycle as the parent it can simply use the parent context, otherwise it should obtain a child context usingSolrMetricsContext.getChildContext(Object)
passingthis
as the child object.scope
- component scope
-
getSolrParamsFromNamedList
public static org.apache.solr.common.params.SolrParams getSolrParamsFromNamedList(org.apache.solr.common.util.NamedList<?> args, String key)
-
getInitArgs
public org.apache.solr.common.util.NamedList<?> getInitArgs()
-
handleRequestBody
public abstract void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception
- Throws:
Exception
-
handleRequest
public void handleRequest(SolrQueryRequest req, SolrQueryResponse rsp)
Description copied from interface:SolrRequestHandler
Handles a query request, this method must be thread safe.Information about the request may be obtained from
req
and response information may be set usingrsp
.There are no mandatory actions that handleRequest must perform. An empty handleRequest implementation would fulfill all interface obligations.
- Specified by:
handleRequest
in interfaceSolrRequestHandler
-
processErrorMetricsOnException
public static void processErrorMetricsOnException(Exception e, RequestHandlerBase.HandlerMetrics metrics)
-
normalizeReceivedException
public static Exception normalizeReceivedException(SolrQueryRequest req, Exception e)
-
getMetricsForThisRequest
public RequestHandlerBase.HandlerMetrics getMetricsForThisRequest(SolrQueryRequest req)
The metrics to be used for this request.
-
getName
public String getName()
Description copied from interface:SolrInfoBean
Simple common usage name, e.g. BasicQueryHandler, or fully qualified class name.- Specified by:
getName
in interfaceSolrInfoBean
-
getDescription
public abstract String getDescription()
Description copied from interface:SolrInfoBean
Simple one or two line description- Specified by:
getDescription
in interfaceSolrInfoBean
-
getCategory
public SolrInfoBean.Category getCategory()
Description copied from interface:SolrInfoBean
Category of this component- Specified by:
getCategory
in interfaceSolrInfoBean
-
getSubHandler
public SolrRequestHandler getSubHandler(String subPath)
Description copied from interface:NestedRequestHandler
Return a RequestHandler to handle a subpath from the path this handler is registered.- Specified by:
getSubHandler
in interfaceNestedRequestHandler
-
getRequestHandler
public static SolrRequestHandler getRequestHandler(String handlerName, PluginBag<SolrRequestHandler> reqHandlers)
Get the request handler registered to a given name.This function is thread safe.
-
setPluginInfo
public void setPluginInfo(PluginInfo pluginInfo)
-
getPluginInfo
public PluginInfo getPluginInfo()
-
getApis
public Collection<Api> getApis()
Description copied from interface:ApiSupport
Returns any (non-JAX-RS annotated) APIs associated with this request handler.- Specified by:
getApis
in interfaceApiSupport
- See Also:
ApiSupport.getJerseyResources()
-
isInternalShardRequest
public static boolean isInternalShardRequest(SolrQueryRequest req)
Checks whether the given request is an internal request to a shard. We rely on the fact that an internal search request to a shard contains the param "isShard", and an internal update request to a shard contains the param "distrib.from".- Returns:
- true if request is internal
-
-