@@ -255,47 +255,6 @@ public static class Builder {
255255 public Builder () {
256256 this .endpoints = new HashSet <>();
257257 this .configuration = new HashMap <String , String >();
258- // TODO: set defaults configuration values
259- this .setConnectTimeout (30 , SECONDS )
260- .setSocketTimeout (2 , SECONDS )
261- .setSocketRcvbuf (804800 )
262- .setSocketSndbuf (804800 )
263- .compressServerResponse (true )
264- .compressClientRequest (false );
265- }
266-
267- /**
268- * Builds a client object with the provided configuration through URL parameters.
269- * (e.g. http://localhost:8123/someDatabase?user=default)
270- * @param urlString - URL formatted string with protocol, host, port, and client configuration settings.
271- * @return Client - a client object
272- */
273- public Builder fromUrl (String urlString ) {
274- try {
275- URL url = new URL (urlString );
276- Map <String , String > urlProperties = HttpAPIClientHelper .parseUrlParameters (url );
277-
278- // Add the endpoint
279- boolean secure = url .getProtocol ().equalsIgnoreCase ("https" );
280- int port = url .getPort ();
281- if (port == -1 ) {
282- port = secure ? ClickHouseHttpProto .DEFAULT_HTTPS_PORT : ClickHouseHttpProto .DEFAULT_HTTP_PORT ;
283- }
284- this .addEndpoint (Protocol .HTTP , url .getHost (), port , secure );
285-
286- for (ClientConfigProperties properties : ClientConfigProperties .values ()) {
287- String value = urlProperties .get (properties .getKey ());
288- if (value != null ) {
289- this .configuration .put (properties .getKey (), value );
290- }
291- }
292-
293- // Set the database
294- } catch (java .net .MalformedURLException e ) {
295- throw new IllegalArgumentException ("Configuration via URL should be done with a valid URL string" , e );
296- }
297-
298- return this ;
299258 }
300259
301260 /**
@@ -520,6 +479,7 @@ public Builder setSocketTimeout(long timeout) {
520479
521480 /**
522481 * Default socket timeout in milliseconds. Timeout is applied to read and write operations.
482+ * Default is 0.
523483 *
524484 * @param timeout - socket timeout value
525485 * @param unit - time unit
@@ -1076,6 +1036,7 @@ public Client build() {
10761036 * Default size for a buffers used in networking.
10771037 */
10781038 public static final int DEFAULT_BUFFER_SIZE = 8192 ;
1039+ public static final int DEFAULT_SOCKET_BUFFER_SIZE = 804800 ;
10791040
10801041 private void setDefaults () {
10811042
@@ -1169,6 +1130,18 @@ private void setDefaults() {
11691130 if (!configuration .containsKey (ClientConfigProperties .APP_COMPRESSED_DATA .getKey ())) {
11701131 appCompressedData (false );
11711132 }
1133+
1134+ if (!configuration .containsKey (ClientConfigProperties .SOCKET_OPERATION_TIMEOUT .getKey ())) {
1135+ setSocketTimeout (0 , SECONDS );
1136+ }
1137+
1138+ if (!configuration .containsKey (ClientConfigProperties .SOCKET_RCVBUF_OPT .getKey ())) {
1139+ setSocketRcvbuf (DEFAULT_SOCKET_BUFFER_SIZE );
1140+ }
1141+
1142+ if (!configuration .containsKey (ClientConfigProperties .SOCKET_SNDBUF_OPT .getKey ())) {
1143+ setSocketSndbuf (DEFAULT_SOCKET_BUFFER_SIZE );
1144+ }
11721145 }
11731146 }
11741147
0 commit comments