disable connection pooling for named pipe
@@ -181,10 +181,12 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.glassfish.hk2.api.MultiException;
import org.glassfish.jersey.apache.connector.ApacheClientProperties;
@@ -447,8 +449,8 @@ public class DefaultDockerClient implements DockerClient, Closeable {
this.uri = originalUri;
}
- final PoolingHttpClientConnectionManager cm = getConnectionManager(builder);
- final PoolingHttpClientConnectionManager noTimeoutCm = getConnectionManager(builder);
+ final HttpClientConnectionManager cm = getConnectionManager(builder);
+ final HttpClientConnectionManager noTimeoutCm = getConnectionManager(builder);
final RequestConfig requestConfig = RequestConfig.custom()
.setConnectionRequestTimeout((int) builder.connectTimeoutMillis)
@@ -535,16 +537,20 @@ public class DefaultDockerClient implements DockerClient, Closeable {
return fromNullable(uri.getHost()).or("localhost");
}
- private PoolingHttpClientConnectionManager getConnectionManager(Builder builder) {
+ private HttpClientConnectionManager getConnectionManager(Builder builder) {
+ if (builder.uri.getScheme().equals(NPIPE_SCHEME)) {
+ final BasicHttpClientConnectionManager bm =
+ new BasicHttpClientConnectionManager(getSchemeRegistry(builder));
+ return bm;
+ } else {
final PoolingHttpClientConnectionManager cm =
new PoolingHttpClientConnectionManager(getSchemeRegistry(builder));
-
// Use all available connections instead of artificially limiting ourselves to 2 per server.
cm.setMaxTotal(builder.connectionPoolSize);
cm.setDefaultMaxPerRoute(cm.getMaxTotal());
-
return cm;
}
+ }
private Registry<ConnectionSocketFactory> getSchemeRegistry(final Builder builder) {
final SSLConnectionSocketFactory https;
