SOLR-8433: Change how HttpClient is initialized in attempt to eliminate test failures

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1723397 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joel Bernstein 2016-01-06 18:16:25 +00:00
parent 71a18c4ddc
commit 9f7f89fc97
1 changed files with 13 additions and 19 deletions

View File

@ -48,15 +48,6 @@ public abstract class IterativeMergeStrategy implements MergeStrategy {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
static {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, 128);
params.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, 32);
HttpClientConfigurer configurer = HttpClientUtil.getConfigurer();
httpClient = HttpClientUtil.createClient(params);
}
public void merge(ResponseBuilder rb, ShardRequest sreq) { public void merge(ResponseBuilder rb, ShardRequest sreq) {
rb._responseDocs = new SolrDocumentList(); // Null pointers will occur otherwise. rb._responseDocs = new SolrDocumentList(); // Null pointers will occur otherwise.
rb.onePassDistributedQuery = true; // Turn off the second pass distributed. rb.onePassDistributedQuery = true; // Turn off the second pass distributed.
@ -94,16 +85,7 @@ public abstract class IterativeMergeStrategy implements MergeStrategy {
public CallBack(ShardResponse originalShardResponse, QueryRequest req) { public CallBack(ShardResponse originalShardResponse, QueryRequest req) {
log.info("############### HttpClientConfigurer ##################:" + HttpClientUtil.getConfigurer().getClass()); this.solrClient = new HttpSolrClient(originalShardResponse.getShardAddress(), getHttpClient());
log.info("################ SHARD ADDRESSS ##############:" + originalShardResponse.getShardAddress());
log.info("############ HTTP Client #############:"+ httpClient.getClass());
List<String> schemes = httpClient.getConnectionManager().getSchemeRegistry().getSchemeNames();
for(String scheme : schemes) {
log.info("############ Scheme #############:"+ scheme);
}
this.solrClient = new HttpSolrClient(originalShardResponse.getShardAddress(), httpClient);
this.req = req; this.req = req;
this.originalShardResponse = originalShardResponse; this.originalShardResponse = originalShardResponse;
req.setMethod(SolrRequest.METHOD.POST); req.setMethod(SolrRequest.METHOD.POST);
@ -139,4 +121,16 @@ public abstract class IterativeMergeStrategy implements MergeStrategy {
protected abstract void process(ResponseBuilder rb, ShardRequest sreq) throws Exception; protected abstract void process(ResponseBuilder rb, ShardRequest sreq) throws Exception;
static synchronized HttpClient getHttpClient() {
if(httpClient == null) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, 128);
params.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, 32);
httpClient = HttpClientUtil.createClient(params);
return httpClient;
} else {
return httpClient;
}
}
} }