Class HttpShardHandlerFactory
- java.lang.Object
-
- org.apache.solr.handler.component.ShardHandlerFactory
-
- org.apache.solr.handler.component.HttpShardHandlerFactory
-
- All Implemented Interfaces:
AutoCloseable,SolrMetricProducer,PluginInfoInitialized
- Direct Known Subclasses:
ParallelHttpShardHandlerFactory
public class HttpShardHandlerFactory extends ShardHandlerFactory implements PluginInfoInitialized, SolrMetricProducer
CreatesHttpShardHandlerinstances
-
-
Field Summary
Fields Modifier and Type Field Description protected ExecutorServicecommExecutorprotected org.apache.solr.client.solrj.impl.Http2SolrClientdefaultClientprotected InstrumentedHttpListenerFactoryhttpListenerFactoryprotected org.apache.solr.client.solrj.impl.LBHttp2SolrClientloadbalancerprotected Randomr-
Fields inherited from class org.apache.solr.handler.component.ShardHandlerFactory
DEFAULT_SHARDHANDLER_INFO
-
-
Constructor Summary
Constructors Constructor Description HttpShardHandlerFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>buildURLList(String shard)Creates a list of urls for the given shard.voidclose()Implementations should always callSolrMetricProducer.super.close()to ensure that metrics with the same life-cycle as this component are properly unregistered.org.apache.solr.client.solrj.SolrClientgetClient()protected <T> TgetParameter(org.apache.solr.common.util.NamedList<?> initArgs, String configKey, T defaultValue, StringBuilder sb)protected org.apache.solr.client.solrj.routing.ReplicaListTransformergetReplicaListTransformer(SolrQueryRequest req)ShardHandlergetShardHandler()GetShardHandlerthat uses the default http client.SolrMetricsContextgetSolrMetricsContext()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.voidinit(PluginInfo info)CustomizesHttpShardHandlerinstances that will be produced by this factory.voidinitializeMetrics(SolrMetricsContext parentContext, String scope)Initialize metrics specific to this producer.protected org.apache.solr.client.solrj.impl.LBSolrClient.ReqnewLBHttpSolrClientReq(org.apache.solr.client.solrj.request.QueryRequest req, List<String> urls)voidsetSecurityBuilder(HttpClientBuilderPlugin clientBuilderPlugin)-
Methods inherited from class org.apache.solr.handler.component.ShardHandlerFactory
newInstance
-
-
-
-
Field Detail
-
commExecutor
protected ExecutorService commExecutor
-
defaultClient
protected volatile org.apache.solr.client.solrj.impl.Http2SolrClient defaultClient
-
httpListenerFactory
protected InstrumentedHttpListenerFactory httpListenerFactory
-
loadbalancer
protected org.apache.solr.client.solrj.impl.LBHttp2SolrClient loadbalancer
-
r
protected final Random r
-
-
Method Detail
-
getShardHandler
public ShardHandler getShardHandler()
GetShardHandlerthat uses the default http client.- Specified by:
getShardHandlerin classShardHandlerFactory
-
init
public void init(PluginInfo info)
CustomizesHttpShardHandlerinstances that will be produced by this factory.Supports the following parameters in
info:- socketTimeout - read timeout for requests, in milliseconds.
- connTimeout - connection timeout for requests, in milliseconds.
- urlScheme - "http" or "https"
- maxConnectionsPerHost - caps the number of concurrent connections per host
- corePoolSize - the initial size of the thread pool used to service requests
- maximumPoolSize - the maximum size of the thread pool used to service requests.
- maxThreadIdleTime - the amount of time (in seconds) that thread pool entries may sit idle before being killed
- sizeOfQueue - the size of the queue (if any) used by the thread pool that services shard-handler requests
- fairnessPolicy - true if the thread pool should prioritize fairness over throughput, false otherwise
- replicaRouting - a NamedList of preferences used to select the order in which replicas for a shard will be used by created ShardHandlers
- Specified by:
initin interfacePluginInfoInitialized- Parameters:
info- configuration for the created factory, typically reflecting the contents of a <shardHandlerFactory> XML tag from solr.xml or solrconfig.xml
-
setSecurityBuilder
public void setSecurityBuilder(HttpClientBuilderPlugin clientBuilderPlugin)
- Overrides:
setSecurityBuilderin classShardHandlerFactory
-
getParameter
protected <T> T getParameter(org.apache.solr.common.util.NamedList<?> initArgs, String configKey, T defaultValue, StringBuilder sb)
-
close
public void close()
Description copied from interface:SolrMetricProducerImplementations should always callSolrMetricProducer.super.close()to ensure that metrics with the same life-cycle as this component are properly unregistered. This prevents obscure memory leaks.from: https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html While this interface method is declared to throw Exception, implementers are strongly encouraged to declare concrete implementations of the close method to throw more specific exceptions, or to throw no exception at all if the close operation cannot fail.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSolrMetricProducer- Specified by:
closein classShardHandlerFactory
-
getSolrMetricsContext
public SolrMetricsContext getSolrMetricsContext()
Description copied from interface:SolrMetricProducerImplementations 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:
getSolrMetricsContextin interfaceSolrMetricProducer
-
newLBHttpSolrClientReq
protected org.apache.solr.client.solrj.impl.LBSolrClient.Req newLBHttpSolrClientReq(org.apache.solr.client.solrj.request.QueryRequest req, List<String> urls)
-
buildURLList
public List<String> buildURLList(String shard)
Creates a list of urls for the given shard.- Parameters:
shard- the urls for the shard, separated by '|'- Returns:
- A list of valid urls (including protocol) that are replicas for the shard
-
getReplicaListTransformer
protected org.apache.solr.client.solrj.routing.ReplicaListTransformer getReplicaListTransformer(SolrQueryRequest req)
-
getClient
public org.apache.solr.client.solrj.SolrClient getClient()
-
initializeMetrics
public void initializeMetrics(SolrMetricsContext parentContext, String scope)
Description copied from interface:SolrMetricProducerInitialize metrics specific to this producer.- Specified by:
initializeMetricsin 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)passingthisas the child object.scope- component scope
-
-