7171
7272import com .arangodb .ArangoDBException ;
7373import com .arangodb .entity .ErrorEntity ;
74+ import com .arangodb .internal .ArangoDBConstants ;
7475import com .arangodb .internal .util .CURLLogger ;
7576import com .arangodb .internal .util .IOUtils ;
7677import com .arangodb .internal .velocystream .Host ;
@@ -101,7 +102,7 @@ public static class Builder {
101102 private Boolean useSsl ;
102103 private SSLContext sslContext ;
103104 // private Integer chunksize;
104- // private Integer maxConnections;
105+ private Integer maxConnections ;
105106
106107 public Builder (final HostHandler hostHandler ) {
107108 super ();
@@ -138,13 +139,13 @@ public Builder sslContext(final SSLContext sslContext) {
138139 // return this;
139140 // }
140141 //
141- // public Builder maxConnections(final Integer maxConnections) {
142- // this.maxConnections = maxConnections;
143- // return this;
144- // }
142+ public Builder maxConnections (final Integer maxConnections ) {
143+ this .maxConnections = maxConnections ;
144+ return this ;
145+ }
145146
146147 public HttpCommunication build (final ArangoSerialization util ) {
147- return new HttpCommunication (timeout , user , password , useSsl , sslContext , util , hostHandler ,
148+ return new HttpCommunication (timeout , user , password , useSsl , sslContext , util , hostHandler , maxConnections ,
148149 HttpContentType .JSON );
149150 }
150151 }
@@ -165,7 +166,7 @@ public HttpCommunication build(final ArangoSerialization util) {
165166
166167 private HttpCommunication (final Integer timeout , final String user , final String password , final Boolean useSsl ,
167168 final SSLContext sslContext , final ArangoSerialization util , final HostHandler hostHandler ,
168- final HttpContentType contentType ) {
169+ final Integer maxConnections , final HttpContentType contentType ) {
169170 super ();
170171 this .user = user ;
171172 this .password = password ;
@@ -185,8 +186,10 @@ private HttpCommunication(final Integer timeout, final String user, final String
185186 a .register ("http" , new PlainConnectionSocketFactory ());
186187 }
187188 cm = new PoolingHttpClientConnectionManager (a .build ());
188- cm .setDefaultMaxPerRoute (20 );// TODO configurable
189- cm .setMaxTotal (20 );// TODO configurable
189+ final int connections = maxConnections != null ? Math .max (1 , maxConnections )
190+ : ArangoDBConstants .MAX_CONNECTIONS_HTTP_DEFAULT ;
191+ cm .setDefaultMaxPerRoute (connections );
192+ cm .setMaxTotal (connections );
190193
191194 final RequestConfig .Builder custom = RequestConfig .custom ();
192195 // if (configure.getConnectionTimeout() >= 0) {
0 commit comments