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 class
HttpShardHandlerFactory.WhitelistHostChecker
Class used to validate the hosts in the "shards" parameter when doing a distributed request
-
Field Summary
Fields Modifier and Type Field Description protected Http2SolrClient
defaultClient
protected InstrumentedHttpListenerFactory
httpListenerFactory
static String
INIT_SHARDS_WHITELIST
protected Random
r
-
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.void
close()
Implementations should always callSolrMetricProducer.super.close()
to ensure that metrics with the same life-cycle as this component are properly unregistered.protected <T> T
getParameter(NamedList initArgs, String configKey, T defaultValue, StringBuilder sb)
protected ReplicaListTransformer
getReplicaListTransformer(SolrQueryRequest req)
ShardHandler
getShardHandler()
GetShardHandler
that uses the default http client.ShardHandler
getShardHandler(org.apache.http.client.HttpClient httpClient)
Deprecated.ShardHandler
getShardHandler(Http2SolrClient httpClient)
GetShardHandler
that uses custom http client.HttpShardHandlerFactory.WhitelistHostChecker
getWhitelistHostChecker()
Returns this Factory'sHttpShardHandlerFactory.WhitelistHostChecker
.void
init(PluginInfo info)
void
initializeMetrics(SolrMetricManager manager, String registry, String tag, String scope)
Initializes metrics specific to this producerLBSolrClient.Rsp
makeLoadBalancedRequest(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.Req
newLBHttpSolrClientReq(QueryRequest req, List<String> urls)
void
setSecurityBuilder(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()
GetShardHandler
that uses the default http client.- Specified by:
getShardHandler
in classShardHandlerFactory
-
getShardHandler
public ShardHandler getShardHandler(Http2SolrClient httpClient)
GetShardHandler
that 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:
init
in interfacePluginInfoInitialized
-
setSecurityBuilder
public void setSecurityBuilder(HttpClientBuilderPlugin clientBuilderPlugin)
- Overrides:
setSecurityBuilder
in classShardHandlerFactory
-
getParameter
protected <T> T getParameter(NamedList initArgs, String configKey, T defaultValue, StringBuilder sb)
-
close
public void close()
Description copied from interface:SolrMetricProducer
Implementations 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceSolrMetricProducer
- Specified by:
close
in 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:
SolrServerException
IOException
-
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:SolrMetricProducer
Initializes metrics specific to this producer- Specified by:
initializeMetrics
in interfaceSolrMetricProducer
- Parameters:
manager
- an instance ofSolrMetricManager
registry
- 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.
-
-