Class HttpShardHandlerFactory
- java.lang.Object
-
- org.apache.solr.handler.component.ShardHandlerFactory
-
- org.apache.solr.handler.component.HttpShardHandlerFactory
-
- All Implemented Interfaces:
AutoCloseable,SolrMetricProducer,PluginInfoInitialized
public class HttpShardHandlerFactory extends ShardHandlerFactory implements PluginInfoInitialized, SolrMetricProducer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHttpShardHandlerFactory.WhitelistHostCheckerClass used to validate the hosts in the "shards" parameter when doing a distributed request
-
Field Summary
Fields Modifier and Type Field Description protected Http2SolrClientdefaultClientprotected InstrumentedHttpListenerFactoryhttpListenerFactorystatic StringINIT_SHARDS_WHITELISTprotected 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 Deprecated 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.protected <T> TgetParameter(NamedList initArgs, String configKey, T defaultValue, StringBuilder sb)protected ReplicaListTransformergetReplicaListTransformer(SolrQueryRequest req)ShardHandlergetShardHandler()GetShardHandlerthat uses the default http client.ShardHandlergetShardHandler(org.apache.http.client.HttpClient httpClient)Deprecated.ShardHandlergetShardHandler(Http2SolrClient httpClient)GetShardHandlerthat uses custom http client.HttpShardHandlerFactory.WhitelistHostCheckergetWhitelistHostChecker()Returns this Factory'sHttpShardHandlerFactory.WhitelistHostChecker.voidinit(PluginInfo info)voidinitializeMetrics(SolrMetricManager manager, String registry, String tag, String scope)Initializes metrics specific to this producerLBSolrClient.RspmakeLoadBalancedRequest(QueryRequest req, List<String> urls)Makes a request to one or more of the given urls, using the configured load balancer.CompletionService<ShardResponse>newCompletionService()Creates a new completion service for use by a single set of distributed requests.protected LBSolrClient.ReqnewLBHttpSolrClientReq(QueryRequest req, List<String> urls)voidsetSecurityBuilder(HttpClientBuilderPlugin clientBuilderPlugin)-
Methods inherited from class org.apache.solr.handler.component.ShardHandlerFactory
newInstance
-
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.metrics.SolrMetricProducer
getSolrMetricsContext, initializeMetrics
-
-
-
-
Field Detail
-
defaultClient
protected volatile Http2SolrClient defaultClient
-
httpListenerFactory
protected InstrumentedHttpListenerFactory httpListenerFactory
-
r
protected final Random r
-
INIT_SHARDS_WHITELIST
public static final String INIT_SHARDS_WHITELIST
- See Also:
- Constant Field Values
-
-
Method Detail
-
getShardHandler
public ShardHandler getShardHandler()
GetShardHandlerthat uses the default http client.- Specified by:
getShardHandlerin classShardHandlerFactory
-
getShardHandler
public ShardHandler getShardHandler(Http2SolrClient httpClient)
GetShardHandlerthat uses custom http client.
-
getShardHandler
@Deprecated public ShardHandler getShardHandler(org.apache.http.client.HttpClient httpClient)
Deprecated.
-
getWhitelistHostChecker
public HttpShardHandlerFactory.WhitelistHostChecker getWhitelistHostChecker()
Returns this Factory'sHttpShardHandlerFactory.WhitelistHostChecker. This method can be overridden to change the checker implementation.
-
init
public void init(PluginInfo info)
- Specified by:
initin interfacePluginInfoInitialized
-
setSecurityBuilder
public void setSecurityBuilder(HttpClientBuilderPlugin clientBuilderPlugin)
- Overrides:
setSecurityBuilderin classShardHandlerFactory
-
getParameter
protected <T> T getParameter(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
-
makeLoadBalancedRequest
public LBSolrClient.Rsp makeLoadBalancedRequest(QueryRequest req, List<String> urls) throws SolrServerException, IOException
Makes a request to one or more of the given urls, using the configured load balancer.- Parameters:
req- The solr search request that should be sent through the load balancerurls- The list of solr server urls to load balance across- Returns:
- The response from the request
- Throws:
SolrServerExceptionIOException
-
newLBHttpSolrClientReq
protected LBSolrClient.Req newLBHttpSolrClientReq(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 ReplicaListTransformer getReplicaListTransformer(SolrQueryRequest req)
-
newCompletionService
public CompletionService<ShardResponse> newCompletionService()
Creates a new completion service for use by a single set of distributed requests.
-
initializeMetrics
public void initializeMetrics(SolrMetricManager manager, String registry, String tag, String scope)
Description copied from interface:SolrMetricProducerInitializes metrics specific to this producer- Specified by:
initializeMetricsin interfaceSolrMetricProducer- Parameters:
manager- an instance ofSolrMetricManagerregistry- registry name where metrics are registeredtag- a symbolic tag that represents this instance of the producer, or a group of related instances that have the same life-cycle. This tag is used when managing life-cycle of some metrics.scope- scope of the metrics (eg. handler name) to separate metrics of components with the same implementation but different scope.
-
-