SOLR-9262: Connection and read timeouts are being ignored by UpdateShardHandler after SOLR-4509

This commit is contained in:
Shalin Shekhar Mangar 2016-07-01 13:16:46 +05:30
parent 6674969a89
commit 51fde1cbf9
3 changed files with 19 additions and 7 deletions

View File

@ -37,7 +37,12 @@ Upgrading from Solr 6.x
* HttpSolrClient#setDefaultMaxConnectionsPerHost and
HttpSolrClient#setMaxTotalConnections have been removed. These now default very
high and can only be changed via param when creating an HttpClient instance.
Bug Fixes
----------------------
* SOLR-9262: Connection and read timeouts are being ignored by UpdateShardHandler after SOLR-4509.
(Mark Miller, shalin)
Optimizations
----------------------

View File

@ -60,8 +60,19 @@ public class UpdateShardHandler {
}
ModifiableSolrParams clientParams = new ModifiableSolrParams();
log.info("Creating UpdateShardHandler HTTP client with params: {}", clientParams);
if (cfg != null) {
clientParams.set(HttpClientUtil.PROP_SO_TIMEOUT, cfg.getDistributedSocketTimeout());
clientParams.set(HttpClientUtil.PROP_CONNECTION_TIMEOUT, cfg.getDistributedConnectionTimeout());
}
client = HttpClientUtil.createClient(clientParams, clientConnectionManager);
// following is done only for logging complete configuration.
// The maxConnections and maxConnectionsPerHost have already been specified on the connection manager
if (cfg != null) {
clientParams.set(HttpClientUtil.PROP_MAX_CONNECTIONS, cfg.getMaxUpdateConnections());
clientParams.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, cfg.getMaxUpdateConnectionsPerHost());
}
log.info("Created UpdateShardHandler HTTP client with params: {}", clientParams);
}
public HttpClient getHttpClient() {

View File

@ -221,10 +221,6 @@ public class HttpClientUtil {
logger.debug("Creating new http client, config:" + config);
}
if (params.get(PROP_SO_TIMEOUT) != null || params.get(PROP_CONNECTION_TIMEOUT) != null) {
throw new SolrException(ErrorCode.SERVER_ERROR, "The socket connect and read timeout cannot be set here and must be set");
}
cm.setMaxTotal(params.getInt(HttpClientUtil.PROP_MAX_CONNECTIONS, 10000));
cm.setDefaultMaxPerRoute(params.getInt(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, 10000));
cm.setValidateAfterInactivity(Integer.getInteger(VALIDATE_AFTER_INACTIVITY, VALIDATE_AFTER_INACTIVITY_DEFAULT));
@ -261,7 +257,7 @@ public class HttpClientUtil {
newHttpClientBuilder = newHttpClientBuilder.setKeepAliveStrategy(keepAliveStrat)
.evictIdleConnections((long) Integer.getInteger(EVICT_IDLE_CONNECTIONS, EVICT_IDLE_CONNECTIONS_DEFAULT), TimeUnit.MILLISECONDS);
HttpClientBuilder builder = setupBuilder(newHttpClientBuilder, params == null ? new ModifiableSolrParams() : params);
HttpClientBuilder builder = setupBuilder(newHttpClientBuilder, params);
HttpClient httpClient = builder.setConnectionManager(cm).build();