mirror of https://github.com/apache/lucene.git
SOLR-4451: SolrJ, and SolrCloud internals, now use SystemDefaultHttpClient under the covers -- allowing many HTTP connection related properties to be controlled via 'standard' java system properties. (hossman)
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1445945 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dc7bec58b1
commit
f16037ec2d
|
@ -48,7 +48,7 @@
|
||||||
<jetty.version>8.1.8.v20121106</jetty.version>
|
<jetty.version>8.1.8.v20121106</jetty.version>
|
||||||
<slf4j.version>1.6.4</slf4j.version>
|
<slf4j.version>1.6.4</slf4j.version>
|
||||||
<tika.version>1.2</tika.version>
|
<tika.version>1.2</tika.version>
|
||||||
<httpcomponents.version>4.1.3</httpcomponents.version>
|
<httpcomponents.version>4.2.3</httpcomponents.version>
|
||||||
|
|
||||||
<!-- RandomizedTesting library system properties -->
|
<!-- RandomizedTesting library system properties -->
|
||||||
<tests.iters>1</tests.iters>
|
<tests.iters>1</tests.iters>
|
||||||
|
|
|
@ -71,6 +71,10 @@ New Features
|
||||||
* SOLR-4370: Allow configuring commitWithin to do hard commits.
|
* SOLR-4370: Allow configuring commitWithin to do hard commits.
|
||||||
(Mark Miller, Senthuran Sivananthan)
|
(Mark Miller, Senthuran Sivananthan)
|
||||||
|
|
||||||
|
* SOLR-4451: SolrJ, and SolrCloud internals, now use SystemDefaultHttpClient
|
||||||
|
under the covers -- allowing many HTTP connection related properties to be
|
||||||
|
controlled via 'standard' java system properties. (hossman)
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
16cf5a6b78951f50713d29bfae3230a611dc01f0
|
|
|
@ -0,0 +1 @@
|
||||||
|
37ced84d839a02fb856255eca85f0a4be95aa634
|
|
@ -1 +0,0 @@
|
||||||
31cc0a151d458c4b99476805ede9c8accafb734c
|
|
|
@ -0,0 +1 @@
|
||||||
|
5e92ec56abe188b865642a14e1a037c1253fc42e
|
|
@ -1 +0,0 @@
|
||||||
d97e400d31bbeb36c1c60d2c3a9bbf2cdccf85a8
|
|
|
@ -0,0 +1 @@
|
||||||
|
118ae1bc7f3aeeddfe564f0edfd79c11d09d17d1
|
|
@ -21,9 +21,9 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency org="org.apache.zookeeper" name="zookeeper" rev="3.4.5" transitive="false"/>
|
<dependency org="org.apache.zookeeper" name="zookeeper" rev="3.4.5" transitive="false"/>
|
||||||
<dependency org="org.apache.httpcomponents" name="httpcore" rev="4.1.4" transitive="false"/>
|
<dependency org="org.apache.httpcomponents" name="httpcore" rev="4.2.3" transitive="false"/>
|
||||||
<dependency org="org.apache.httpcomponents" name="httpclient" rev="4.1.3" transitive="false"/>
|
<dependency org="org.apache.httpcomponents" name="httpclient" rev="4.2.3" transitive="false"/>
|
||||||
<dependency org="org.apache.httpcomponents" name="httpmime" rev="4.1.3" transitive="false"/>
|
<dependency org="org.apache.httpcomponents" name="httpmime" rev="4.2.3" transitive="false"/>
|
||||||
<dependency org="commons-io" name="commons-io" rev="${commons-io.version}" transitive="false"/>
|
<dependency org="commons-io" name="commons-io" rev="${commons-io.version}" transitive="false"/>
|
||||||
<dependency org="org.slf4j" name="jcl-over-slf4j" rev="1.6.4" transitive="false"/>
|
<dependency org="org.slf4j" name="jcl-over-slf4j" rev="1.6.4" transitive="false"/>
|
||||||
<dependency org="org.codehaus.woodstox" name="wstx-asl" rev="3.2.7" transitive="false"/>
|
<dependency org="org.codehaus.woodstox" name="wstx-asl" rev="3.2.7" transitive="false"/>
|
||||||
|
|
|
@ -79,8 +79,7 @@ public class ConcurrentUpdateSolrServer extends SolrServer {
|
||||||
final int threadCount;
|
final int threadCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses an internal ThreadSafeClientConnManager to manage http
|
* Uses an internaly managed HttpClient instance.
|
||||||
* connections.
|
|
||||||
*
|
*
|
||||||
* @param solrServerUrl
|
* @param solrServerUrl
|
||||||
* The Solr server URL
|
* The Solr server URL
|
||||||
|
@ -95,9 +94,7 @@ public class ConcurrentUpdateSolrServer extends SolrServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses the supplied HttpClient to send documents to the Solr server, the
|
* Uses the supplied HttpClient to send documents to the Solr server.
|
||||||
* HttpClient should be instantiated using a
|
|
||||||
* ThreadSafeClientConnManager.
|
|
||||||
*/
|
*/
|
||||||
public ConcurrentUpdateSolrServer(String solrServerUrl,
|
public ConcurrentUpdateSolrServer(String solrServerUrl,
|
||||||
HttpClient client, int queueSize, int threadCount) {
|
HttpClient client, int queueSize, int threadCount) {
|
||||||
|
|
|
@ -35,8 +35,10 @@ import org.apache.http.client.HttpClient;
|
||||||
import org.apache.http.client.params.ClientParamBean;
|
import org.apache.http.client.params.ClientParamBean;
|
||||||
import org.apache.http.entity.HttpEntityWrapper;
|
import org.apache.http.entity.HttpEntityWrapper;
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
|
import org.apache.http.impl.client.SystemDefaultHttpClient;
|
||||||
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
|
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
|
||||||
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
|
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; // jdoc
|
||||||
|
import org.apache.http.impl.conn.PoolingClientConnectionManager;
|
||||||
import org.apache.http.params.HttpConnectionParams;
|
import org.apache.http.params.HttpConnectionParams;
|
||||||
import org.apache.http.protocol.HttpContext;
|
import org.apache.http.protocol.HttpContext;
|
||||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||||
|
@ -94,14 +96,12 @@ public class HttpClientUtil {
|
||||||
*
|
*
|
||||||
* @param params
|
* @param params
|
||||||
* http client configuration, if null a client with default
|
* http client configuration, if null a client with default
|
||||||
* configuration (no additional configuration) is created that uses
|
* configuration (no additional configuration) is created.
|
||||||
* ThreadSafeClientConnManager.
|
|
||||||
*/
|
*/
|
||||||
public static HttpClient createClient(final SolrParams params) {
|
public static HttpClient createClient(final SolrParams params) {
|
||||||
final ModifiableSolrParams config = new ModifiableSolrParams(params);
|
final ModifiableSolrParams config = new ModifiableSolrParams(params);
|
||||||
logger.info("Creating new http client, config:" + config);
|
logger.info("Creating new http client, config:" + config);
|
||||||
final ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager();
|
final DefaultHttpClient httpClient = new SystemDefaultHttpClient();
|
||||||
final DefaultHttpClient httpClient = new DefaultHttpClient(mgr);
|
|
||||||
configureClient(httpClient, config);
|
configureClient(httpClient, config);
|
||||||
return httpClient;
|
return httpClient;
|
||||||
}
|
}
|
||||||
|
@ -153,25 +153,35 @@ public class HttpClientUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set max connections allowed per host. This call will only work when
|
* Set max connections allowed per host. This call will only work when
|
||||||
* {@link ThreadSafeClientConnManager} is used.
|
* {@link ThreadSafeClientConnManager} or
|
||||||
|
* {@link PoolingClientConnectionManager} is used.
|
||||||
*/
|
*/
|
||||||
public static void setMaxConnectionsPerHost(HttpClient httpClient,
|
public static void setMaxConnectionsPerHost(HttpClient httpClient,
|
||||||
int max) {
|
int max) {
|
||||||
|
// would have been nice if there was a common interface
|
||||||
if (httpClient.getConnectionManager() instanceof ThreadSafeClientConnManager) {
|
if (httpClient.getConnectionManager() instanceof ThreadSafeClientConnManager) {
|
||||||
ThreadSafeClientConnManager mgr = (ThreadSafeClientConnManager)httpClient.getConnectionManager();
|
ThreadSafeClientConnManager mgr = (ThreadSafeClientConnManager)httpClient.getConnectionManager();
|
||||||
mgr.setDefaultMaxPerRoute(max);
|
mgr.setDefaultMaxPerRoute(max);
|
||||||
|
} else if (httpClient.getConnectionManager() instanceof PoolingClientConnectionManager) {
|
||||||
|
PoolingClientConnectionManager mgr = (PoolingClientConnectionManager)httpClient.getConnectionManager();
|
||||||
|
mgr.setDefaultMaxPerRoute(max);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set max total connections allowed. This call will only work when
|
* Set max total connections allowed. This call will only work when
|
||||||
* {@link ThreadSafeClientConnManager} is used.
|
* {@link ThreadSafeClientConnManager} or
|
||||||
|
* {@link PoolingClientConnectionManager} is used.
|
||||||
*/
|
*/
|
||||||
public static void setMaxConnections(final HttpClient httpClient,
|
public static void setMaxConnections(final HttpClient httpClient,
|
||||||
int max) {
|
int max) {
|
||||||
|
// would have been nice if there was a common interface
|
||||||
if (httpClient.getConnectionManager() instanceof ThreadSafeClientConnManager) {
|
if (httpClient.getConnectionManager() instanceof ThreadSafeClientConnManager) {
|
||||||
ThreadSafeClientConnManager mgr = (ThreadSafeClientConnManager)httpClient.getConnectionManager();
|
ThreadSafeClientConnManager mgr = (ThreadSafeClientConnManager)httpClient.getConnectionManager();
|
||||||
mgr.setMaxTotal(max);
|
mgr.setMaxTotal(max);
|
||||||
|
} else if (httpClient.getConnectionManager() instanceof PoolingClientConnectionManager) {
|
||||||
|
PoolingClientConnectionManager mgr = (PoolingClientConnectionManager)httpClient.getConnectionManager();
|
||||||
|
mgr.setMaxTotal(max);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import org.apache.http.auth.AuthScope;
|
import org.apache.http.auth.AuthScope;
|
||||||
import org.apache.http.client.HttpClient;
|
import org.apache.http.client.HttpClient;
|
||||||
import org.apache.http.client.params.ClientPNames;
|
import org.apache.http.client.params.ClientPNames;
|
||||||
|
import org.apache.http.impl.conn.PoolingClientConnectionManager;
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
|
|
||||||
import org.apache.http.params.HttpConnectionParams;
|
import org.apache.http.params.HttpConnectionParams;
|
||||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||||
import org.apache.solr.common.params.SolrParams;
|
import org.apache.solr.common.params.SolrParams;
|
||||||
|
@ -52,9 +52,9 @@ public class HttpClientUtilTest {
|
||||||
params.set(HttpClientUtil.PROP_USE_RETRY, false);
|
params.set(HttpClientUtil.PROP_USE_RETRY, false);
|
||||||
DefaultHttpClient client = (DefaultHttpClient) HttpClientUtil.createClient(params);
|
DefaultHttpClient client = (DefaultHttpClient) HttpClientUtil.createClient(params);
|
||||||
assertEquals(12345, HttpConnectionParams.getConnectionTimeout(client.getParams()));
|
assertEquals(12345, HttpConnectionParams.getConnectionTimeout(client.getParams()));
|
||||||
assertEquals(ThreadSafeClientConnManager.class, client.getConnectionManager().getClass());
|
assertEquals(PoolingClientConnectionManager.class, client.getConnectionManager().getClass());
|
||||||
assertEquals(22345, ((ThreadSafeClientConnManager)client.getConnectionManager()).getMaxTotal());
|
assertEquals(22345, ((PoolingClientConnectionManager)client.getConnectionManager()).getMaxTotal());
|
||||||
assertEquals(32345, ((ThreadSafeClientConnManager)client.getConnectionManager()).getDefaultMaxPerRoute());
|
assertEquals(32345, ((PoolingClientConnectionManager)client.getConnectionManager()).getDefaultMaxPerRoute());
|
||||||
assertEquals(42345, HttpConnectionParams.getSoTimeout(client.getParams()));
|
assertEquals(42345, HttpConnectionParams.getSoTimeout(client.getParams()));
|
||||||
assertEquals(HttpClientUtil.NO_RETRY, client.getHttpRequestRetryHandler());
|
assertEquals(HttpClientUtil.NO_RETRY, client.getHttpRequestRetryHandler());
|
||||||
assertEquals("pass", client.getCredentialsProvider().getCredentials(new AuthScope("127.0.0.1", 1234)).getPassword());
|
assertEquals("pass", client.getCredentialsProvider().getCredentials(new AuthScope("127.0.0.1", 1234)).getPassword());
|
||||||
|
|
|
@ -7,7 +7,6 @@ import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
|
||||||
import org.apache.solr.client.solrj.ResponseParser;
|
import org.apache.solr.client.solrj.ResponseParser;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -28,6 +27,8 @@ import org.junit.Test;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the LBHttpSolrServer.
|
* Test the LBHttpSolrServer.
|
||||||
*/
|
*/
|
||||||
|
@ -42,12 +43,12 @@ public class LBHttpSolrServerTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLBHttpSolrServerHttpClientResponseParserStringArray() throws MalformedURLException {
|
public void testLBHttpSolrServerHttpClientResponseParserStringArray() throws MalformedURLException {
|
||||||
LBHttpSolrServer testServer = new LBHttpSolrServer(new DefaultHttpClient(), (ResponseParser) null);
|
LBHttpSolrServer testServer = new LBHttpSolrServer(HttpClientUtil.createClient(new ModifiableSolrParams()), (ResponseParser) null);
|
||||||
HttpSolrServer httpServer = testServer.makeServer("http://127.0.0.1:8080");
|
HttpSolrServer httpServer = testServer.makeServer("http://127.0.0.1:8080");
|
||||||
assertNull("Generated server should have null parser.", httpServer.getParser());
|
assertNull("Generated server should have null parser.", httpServer.getParser());
|
||||||
|
|
||||||
ResponseParser parser = new BinaryResponseParser();
|
ResponseParser parser = new BinaryResponseParser();
|
||||||
testServer = new LBHttpSolrServer(new DefaultHttpClient(), parser);
|
testServer = new LBHttpSolrServer(HttpClientUtil.createClient(new ModifiableSolrParams()), parser);
|
||||||
httpServer = testServer.makeServer("http://127.0.0.1:8080");
|
httpServer = testServer.makeServer("http://127.0.0.1:8080");
|
||||||
assertEquals("Invalid parser passed to generated server.", parser, httpServer.getParser());
|
assertEquals("Invalid parser passed to generated server.", parser, httpServer.getParser());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue