Skip to content
Permalink
Browse files

Apply remote solr configured timeout on getting connection from pool

  • Loading branch information...
luccioman committed Jun 2, 2018
1 parent a199020 commit a7a4ba32871683b9c383927d075e970fe8bf3ba4
Showing with 8 additions and 0 deletions.
  1. +8 −0 source/net/yacy/cora/federate/solr/instance/RemoteInstance.java
@@ -43,6 +43,7 @@
import org.apache.http.client.AuthCache;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.GzipDecompressingEntity;
import org.apache.http.client.params.HttpClientParams;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
@@ -51,6 +52,7 @@
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.HTTP;
import org.apache.http.protocol.HttpContext;
import org.apache.http.ssl.SSLContextBuilder;
@@ -193,6 +195,10 @@ public RemoteInstance(final String url, final Collection<String> coreNames, fina
final ModifiableSolrParams params = new ModifiableSolrParams();
params.set(HttpClientUtil.PROP_FOLLOW_REDIRECTS, false);
this.client = HttpClientUtil.createClient(params, CONNECTION_MANAGER);
if(this.client instanceof DefaultHttpClient && this.client.getParams() != null) {
/* Set the maximum time to get a connection from the shared connections pool */
HttpClientParams.setConnectionManagerTimeout(this.client.getParams(), timeout);
}
}

this.defaultServer = (ConcurrentUpdateSolrClient) getServer(this.defaultCoreName);
@@ -273,6 +279,8 @@ protected HttpContext createHttpContext() {
org.apache.http.params.HttpConnectionParams.setConnectionTimeout(params, timeout);
/* Set the maximum time between data packets reception one a connection has been established */
org.apache.http.params.HttpConnectionParams.setSoTimeout(params, timeout);
/* Set the maximum time to get a connection from the shared connections pool */
HttpClientParams.setConnectionManagerTimeout(params, timeout);
result.addRequestInterceptor(new HttpRequestInterceptor() {
@Override
public void process(final HttpRequest request, final HttpContext context) throws IOException {

0 comments on commit a7a4ba3

Please sign in to comment.
You can’t perform that action at this time.