mirror of https://github.com/apache/lucene.git
SOLR-4981: Share HttpClient across SolrServers and shut it down on close
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1498540 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b48deb09df
commit
8227df4c04
|
@ -62,8 +62,8 @@ public class SyncStrategy {
|
||||||
|
|
||||||
private volatile boolean isClosed;
|
private volatile boolean isClosed;
|
||||||
|
|
||||||
private final static HttpClient client;
|
private final HttpClient client;
|
||||||
static {
|
{
|
||||||
ModifiableSolrParams params = new ModifiableSolrParams();
|
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||||
params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, 10000);
|
params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, 10000);
|
||||||
params.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, 20);
|
params.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, 20);
|
||||||
|
@ -112,20 +112,6 @@ public class SyncStrategy {
|
||||||
log.info("We have been closed, won't sync with replicas");
|
log.info("We have been closed, won't sync with replicas");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// if no one that is up is active, we are willing to wait...
|
|
||||||
// we don't want a recovering node to become leader and then
|
|
||||||
// a better candidate pops up a second later.
|
|
||||||
// int tries = 20;
|
|
||||||
// while (!areAnyReplicasActive(zkController, collection, shardId)) {
|
|
||||||
// if (tries-- == 0) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// try {
|
|
||||||
// Thread.sleep(500);
|
|
||||||
// } catch (InterruptedException e) {
|
|
||||||
// Thread.currentThread().interrupt();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// first sync ourselves - we are the potential leader after all
|
// first sync ourselves - we are the potential leader after all
|
||||||
try {
|
try {
|
||||||
|
@ -271,6 +257,11 @@ public class SyncStrategy {
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
this.isClosed = true;
|
this.isClosed = true;
|
||||||
|
try {
|
||||||
|
client.getConnectionManager().shutdown();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
SolrException.log(log, e);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
ExecutorUtil.shutdownNowAndAwaitTermination(recoveryCmdExecutor);
|
ExecutorUtil.shutdownNowAndAwaitTermination(recoveryCmdExecutor);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
@ -289,7 +280,7 @@ public class SyncStrategy {
|
||||||
recoverRequestCmd.setAction(CoreAdminAction.REQUESTRECOVERY);
|
recoverRequestCmd.setAction(CoreAdminAction.REQUESTRECOVERY);
|
||||||
recoverRequestCmd.setCoreName(coreName);
|
recoverRequestCmd.setCoreName(coreName);
|
||||||
|
|
||||||
HttpSolrServer server = new HttpSolrServer(baseUrl);
|
HttpSolrServer server = new HttpSolrServer(baseUrl, client);
|
||||||
server.setConnectionTimeout(45000);
|
server.setConnectionTimeout(45000);
|
||||||
server.setSoTimeout(45000);
|
server.setSoTimeout(45000);
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue