@@ -33,6 +33,9 @@ public class DockerClientConfig implements Serializable {
3333 private static final String DOCKER_IO_ENABLE_LOGGING_FILTER_PROPERTY = "docker.io.enableLoggingFilter" ;
3434 private static final String DOCKER_IO_DOCKER_CERT_PATH_PROPERTY = "docker.io.dockerCertPath" ;
3535 private static final String DOCKER_IO_DOCKER_CFG_PATH_PROPERTY = "docker.io.dockerCfgPath" ;
36+ // connection pooling properties
37+ private static final String DOCKER_IO_MAX_PER_ROUTE_PROPERTY = "docker.io.perRouteConnections" ;
38+ private static final String DOCKER_IO_MAX_TOTAL_PROPERTY = "docker.io.totalConnections" ;
3639 /**
3740 * A map from the environment name to the interval name.
3841 */
@@ -49,13 +52,18 @@ public class DockerClientConfig implements Serializable {
4952 .put ("DOCKER_CFG_PATH" , DOCKER_IO_DOCKER_CFG_PATH_PROPERTY )
5053 .build ();
5154 private static final String DOCKER_IO_PROPERTIES_PROPERTY = "docker.io.properties" ;
52- private final URI uri ;
55+ private URI uri ;
5356 private final String version , username , password , email , serverAddress , dockerCfgPath ;
5457 private final Integer readTimeout ;
5558 private final boolean loggingFilterEnabled ;
5659 private final SSLConfig sslConfig ;
60+
61+ private final int maxTotalConnections ;
62+ private final int maxPerRouteConnections ;
5763
58- DockerClientConfig (URI uri , String version , String username , String password , String email , String serverAddress , String dockerCfgPath , Integer readTimeout , boolean loggingFilterEnabled , SSLConfig sslConfig ) {
64+ DockerClientConfig (URI uri , String version , String username , String password , String email , String serverAddress ,
65+ String dockerCfgPath , Integer readTimeout , boolean loggingFilterEnabled , SSLConfig sslConfig ,
66+ int maxTotalConns , int maxPerRouteConns ) {
5967 this .uri = uri ;
6068 this .version = version ;
6169 this .username = username ;
@@ -66,6 +74,8 @@ public class DockerClientConfig implements Serializable {
6674 this .readTimeout = readTimeout ;
6775 this .loggingFilterEnabled = loggingFilterEnabled ;
6876 this .sslConfig = sslConfig ;
77+ this .maxTotalConnections = maxTotalConns ;
78+ this .maxPerRouteConnections = maxPerRouteConns ;
6979 }
7080
7181 private static Properties loadIncludedDockerProperties (Properties systemProperties ) {
@@ -194,6 +204,10 @@ public URI getUri() {
194204 return uri ;
195205 }
196206
207+ public void setUri (URI uri ) {
208+ this .uri = uri ;
209+ }
210+
197211 public String getVersion () {
198212 return version ;
199213 }
@@ -329,7 +343,7 @@ public String toString() {
329343 public static class DockerClientConfigBuilder {
330344 private URI uri ;
331345 private String version , username , password , email , serverAddress , dockerCfgPath ;
332- private Integer readTimeout ;
346+ private Integer readTimeout , maxTotalConnections , maxPerRouteConnections ;
333347 private boolean loggingFilterEnabled ;
334348 private SSLConfig sslConfig ;
335349
@@ -349,7 +363,10 @@ public DockerClientConfigBuilder withProperties(Properties p) {
349363 .withReadTimeout (Integer .valueOf (p .getProperty (DOCKER_IO_READ_TIMEOUT_PROPERTY , "0" )))
350364 .withLoggingFilter (Boolean .valueOf (p .getProperty (DOCKER_IO_ENABLE_LOGGING_FILTER_PROPERTY , "true" )))
351365 .withDockerCertPath (p .getProperty (DOCKER_IO_DOCKER_CERT_PATH_PROPERTY ))
352- .withDockerCfgPath (p .getProperty (DOCKER_IO_DOCKER_CFG_PATH_PROPERTY ));
366+ .withDockerCfgPath (p .getProperty (DOCKER_IO_DOCKER_CFG_PATH_PROPERTY ))
367+ .withMaxPerRouteConnections (Integer .valueOf (p .getProperty (DOCKER_IO_MAX_PER_ROUTE_PROPERTY , "2" )))
368+ .withMaxTotalConnections (Integer .valueOf (p .getProperty (DOCKER_IO_MAX_TOTAL_PROPERTY , "20" )))
369+ ;
353370 }
354371
355372 public final DockerClientConfigBuilder withUri (String uri ) {
@@ -387,6 +404,16 @@ public final DockerClientConfigBuilder withReadTimeout(Integer readTimeout) {
387404 this .readTimeout = readTimeout ;
388405 return this ;
389406 }
407+
408+ public final DockerClientConfigBuilder withMaxTotalConnections (Integer maxTotalConnections ) {
409+ this .maxTotalConnections = maxTotalConnections ;
410+ return this ;
411+ }
412+
413+ public final DockerClientConfigBuilder withMaxPerRouteConnections (Integer maxPerRouteConnections ) {
414+ this .maxPerRouteConnections = maxPerRouteConnections ;
415+ return this ;
416+ }
390417
391418 public final DockerClientConfigBuilder withLoggingFilter (boolean loggingFilterEnabled ) {
392419 this .loggingFilterEnabled = loggingFilterEnabled ;
@@ -420,8 +447,18 @@ public DockerClientConfig build() {
420447 dockerCfgPath ,
421448 readTimeout ,
422449 loggingFilterEnabled ,
423- sslConfig
450+ sslConfig ,
451+ maxTotalConnections ,
452+ maxPerRouteConnections
424453 );
425454 }
426455 }
456+
457+ public int getMaxTotalConnections () {
458+ return maxTotalConnections ;
459+ }
460+
461+ public int getMaxPerRoutConnections () {
462+ return maxPerRouteConnections ;
463+ }
427464}
0 commit comments