Class HttpShardHandlerFactory
- java.lang.Object
-
- org.apache.solr.handler.component.ShardHandlerFactory
-
- org.apache.solr.handler.component.HttpShardHandlerFactory
-
- All Implemented Interfaces:
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 InstrumentedPoolingHttpClientConnectionManager
clientConnectionManager
protected org.apache.http.impl.client.CloseableHttpClient
defaultClient
protected InstrumentedHttpRequestExecutor
httpRequestExecutor
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 Modifier and Type Method Description List<String>
buildURLList(String shard)
Creates a list of urls for the given shard.void
close()
protected LBHttpSolrClient
createLoadbalancer(org.apache.http.client.HttpClient httpClient)
protected ModifiableSolrParams
getClientParams()
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)
GetShardHandler
that uses custom http client.protected ExecutorService
getThreadPoolExecutor()
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 producer.LBHttpSolrClient.Rsp
makeLoadBalancedRequest(QueryRequest req, List<String> urls)
Makes a request to one or more of the given urls, using the configured load balancer.CompletionService
newCompletionService()
Creates a new completion service for use by a single set of distributed requests.protected LBHttpSolrClient.Req
newLBHttpSolrClientReq(QueryRequest req, List<String> urls)
-
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
initializeMetrics
-
-
-
-
Field Detail
-
clientConnectionManager
protected InstrumentedPoolingHttpClientConnectionManager clientConnectionManager
-
defaultClient
protected org.apache.http.impl.client.CloseableHttpClient defaultClient
-
httpRequestExecutor
protected InstrumentedHttpRequestExecutor httpRequestExecutor
-
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(org.apache.http.client.HttpClient httpClient)
GetShardHandler
that uses custom http client.
-
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
-
getClientParams
protected ModifiableSolrParams getClientParams()
-
getThreadPoolExecutor
protected ExecutorService getThreadPoolExecutor()
-
createLoadbalancer
protected LBHttpSolrClient createLoadbalancer(org.apache.http.client.HttpClient httpClient)
-
getParameter
protected <T> T getParameter(NamedList initArgs, String configKey, T defaultValue, StringBuilder sb)
-
close
public void close()
- Specified by:
close
in classShardHandlerFactory
-
makeLoadBalancedRequest
public LBHttpSolrClient.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 LBHttpSolrClient.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 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.Note: for back-compatibility this method by default calls
SolrMetricProducer.initializeMetrics(SolrMetricManager, String, String)
.- Specified by:
initializeMetrics
in interfaceSolrMetricProducer
- Parameters:
manager
- an instance ofSolrMetricManager
registry
- registry name where metrics are registeredtag
- symbolic tag that represents a group of related instances that have the same life-cycle. Parent component can use thetag
when callingSolrMetricManager.unregisterGauges(String, String)
to unregister metrics created by this instance of the producer.scope
- scope of the metrics (eg. handler name) to separate metrics of instances of the same component executing in different contexts
-
-