54
54
* <li><code>defaultTags</code> - defaultTags added when writing points to InfluxDB</li>
55
55
* <li><code>gzipThreshold</code> - threshold when gzip compression is used for writing points to InfluxDB</li>
56
56
* <li><code>writeNoSync</code> - skip waiting for WAL persistence on write</li>
57
- * <li><code>responseTimeout</code> - timeout when connecting to InfluxDB</li>
57
+ * <li><code>timeout</code> - <i>deprecated in 1.4.0</i> timeout when connecting to InfluxDB,
58
+ * please use more informative properties <code>writeTimeout</code> and <code>queryTimeout</code></li>
59
+ * <li><code>writeTimeout</code> - timeout when writing data to InfluxDB</li>
60
+ * <li><code>queryTimeout</code> - timeout used to calculate a default gRPC deadline when querying InfluxDB.
61
+ * Can be <code>null</code>, in which case queries can potentially run forever.</li>
58
62
* <li><code>allowHttpRedirects</code> - allow redirects for InfluxDB connections</li>
59
63
* <li><code>disableServerCertificateValidation</code> -
60
64
* disable server certificate validation for HTTPS connections
@@ -99,7 +103,10 @@ public final class ClientConfig {
99
103
private final Integer gzipThreshold ;
100
104
private final Boolean writeNoSync ;
101
105
private final Map <String , String > defaultTags ;
106
+ @ Deprecated
102
107
private final Duration timeout ;
108
+ private final Duration writeTimeout ;
109
+ private final Duration queryTimeout ;
103
110
private final Boolean allowHttpRedirects ;
104
111
private final Boolean disableServerCertificateValidation ;
105
112
private final String proxyUrl ;
@@ -203,15 +210,42 @@ public Map<String, String> getDefaultTags() {
203
210
}
204
211
205
212
/**
206
- * Gets the default timeout to use for the API calls. Default to '10 seconds'.
213
+ * Gets the default timeout to use for write API calls.
214
+ * Defaults to '{@value com.influxdb.v3.client.write.WriteOptions#DEFAULT_WRITE_TIMEOUT} seconds'.
215
+ * <p>
216
+ * Deprecated in v1.4.0. Please use more informative <code>getWriteTimeout()</code>.
207
217
*
208
- * @return the default timeout to use for the API calls
218
+ * @return the default timeout to use for write API calls
219
+ * @see #getWriteTimeout()
209
220
*/
210
221
@ Nonnull
222
+ @ Deprecated
211
223
public Duration getTimeout () {
212
224
return timeout ;
213
225
}
214
226
227
+ /**
228
+ * Gets the default timeout to use for REST Write API calls. Default is
229
+ * {@value com.influxdb.v3.client.write.WriteOptions#DEFAULT_WRITE_TIMEOUT} seconds.
230
+ *
231
+ * @return the default timeout to use for REST Write API calls.
232
+ */
233
+ @ Nonnull
234
+ public Duration getWriteTimeout () {
235
+ return writeTimeout ;
236
+ }
237
+
238
+ /**
239
+ * Gets the default timeout Duration to use for calculating a gRPC Deadline when making Query API calls.
240
+ * Can be null, in which case queries can potentially wait or run forever.
241
+ *
242
+ * @return the default timeout Duration to use for Query API calls.
243
+ */
244
+ @ Nullable
245
+ public Duration getQueryTimeout () {
246
+ return queryTimeout ;
247
+ }
248
+
215
249
/**
216
250
* Gets the automatically following HTTP 3xx redirects. Default to 'false'.
217
251
*
@@ -312,6 +346,8 @@ public boolean equals(final Object o) {
312
346
&& Objects .equals (writeNoSync , that .writeNoSync )
313
347
&& Objects .equals (defaultTags , that .defaultTags )
314
348
&& Objects .equals (timeout , that .timeout )
349
+ && Objects .equals (writeTimeout , that .writeTimeout )
350
+ && Objects .equals (queryTimeout , that .queryTimeout )
315
351
&& Objects .equals (allowHttpRedirects , that .allowHttpRedirects )
316
352
&& Objects .equals (disableServerCertificateValidation , that .disableServerCertificateValidation )
317
353
&& Objects .equals (proxy , that .proxy )
@@ -325,7 +361,7 @@ public boolean equals(final Object o) {
325
361
public int hashCode () {
326
362
return Objects .hash (host , Arrays .hashCode (token ), authScheme , organization ,
327
363
database , writePrecision , gzipThreshold , writeNoSync ,
328
- timeout , allowHttpRedirects , disableServerCertificateValidation ,
364
+ timeout , writeTimeout , queryTimeout , allowHttpRedirects , disableServerCertificateValidation ,
329
365
proxy , proxyUrl , authenticator , headers ,
330
366
defaultTags , sslRootsFilePath );
331
367
}
@@ -340,6 +376,8 @@ public String toString() {
340
376
.add ("gzipThreshold=" + gzipThreshold )
341
377
.add ("writeNoSync=" + writeNoSync )
342
378
.add ("timeout=" + timeout )
379
+ .add ("writeTimeout=" + writeTimeout )
380
+ .add ("queryTimeout=" + queryTimeout )
343
381
.add ("allowHttpRedirects=" + allowHttpRedirects )
344
382
.add ("disableServerCertificateValidation=" + disableServerCertificateValidation )
345
383
.add ("proxy=" + proxy )
@@ -366,7 +404,10 @@ public static final class Builder {
366
404
private Integer gzipThreshold ;
367
405
private Boolean writeNoSync ;
368
406
private Map <String , String > defaultTags ;
407
+ @ Deprecated
369
408
private Duration timeout ;
409
+ private Duration writeTimeout ;
410
+ private Duration queryTimeout ;
370
411
private Boolean allowHttpRedirects ;
371
412
private Boolean disableServerCertificateValidation ;
372
413
private ProxySelector proxy ;
@@ -496,18 +537,55 @@ public Builder defaultTags(@Nullable final Map<String, String> defaultTags) {
496
537
}
497
538
498
539
/**
499
- * Sets the default timeout to use for the API calls. Default to '10 seconds'.
540
+ * Sets the default timeout to use for Write API calls. Defaults to
541
+ * '{@value com.influxdb.v3.client.write.WriteOptions#DEFAULT_WRITE_TIMEOUT} seconds'.
542
+ * <p>
543
+ * Deprecated in v1.4.0. This setter is superseded by the clearer <code>writeTimeout()</code>.
500
544
*
501
- * @param timeout default timeout to use for the API calls. Default to '10 seconds'.
545
+ * @param timeout default timeout to use for Write API calls. Default to
546
+ * ''{@value com.influxdb.v3.client.write.WriteOptions#DEFAULT_WRITE_TIMEOUT} seconds'.
502
547
* @return this
548
+ *
549
+ * @see #writeTimeout(Duration writeTimeout)
503
550
*/
551
+ @ Deprecated
504
552
@ Nonnull
505
553
public Builder timeout (@ Nullable final Duration timeout ) {
506
554
507
555
this .timeout = timeout ;
508
556
return this ;
509
557
}
510
558
559
+ /**
560
+ * Sets the default writeTimeout to use for Write API calls in the REST client.
561
+ * Default is {@value com.influxdb.v3.client.write.WriteOptions#DEFAULT_WRITE_TIMEOUT}
562
+ *
563
+ * @param writeTimeout default timeout to use for REST API write calls. Default is
564
+ * {@value com.influxdb.v3.client.write.WriteOptions#DEFAULT_WRITE_TIMEOUT}
565
+ * @return - this
566
+ */
567
+ @ Nonnull
568
+ public Builder writeTimeout (@ Nullable final Duration writeTimeout ) {
569
+
570
+ this .writeTimeout = writeTimeout ;
571
+ return this ;
572
+ }
573
+
574
+ /**
575
+ * Sets standard query timeout used to calculate a gRPC deadline when making Query API calls.
576
+ * If <code>null</code>, queries can potentially wait or run forever.
577
+ *
578
+ * @param queryTimeout default timeout used to calculate deadline for Query API calls.
579
+ * If <code>null</code>, queries can potentially wait or run forever.
580
+ * Default value is <code>null</code>.
581
+ * @return this
582
+ */
583
+ @ Nonnull
584
+ public Builder queryTimeout (@ Nullable final Duration queryTimeout ) {
585
+ this .queryTimeout = queryTimeout ;
586
+ return this ;
587
+ }
588
+
511
589
/**
512
590
* Sets the automatically following HTTP 3xx redirects. Default to 'false'.
513
591
*
@@ -719,6 +797,16 @@ public ClientConfig build(@Nonnull final Map<String, String> env, final Properti
719
797
if (writeNoSync != null ) {
720
798
this .writeNoSync (Boolean .parseBoolean (writeNoSync ));
721
799
}
800
+ final String writeTimeout = get .apply ("INFLUX_WRITE_TIMEOUT" , "influx.writeTimeout" );
801
+ if (writeTimeout != null ) {
802
+ long to = Long .parseLong (writeTimeout );
803
+ this .writeTimeout (Duration .ofSeconds (to ));
804
+ }
805
+ final String queryTimeout = get .apply ("INFLUX_QUERY_TIMEOUT" , "influx.queryTimeout" );
806
+ if (queryTimeout != null ) {
807
+ long to = Long .parseLong (queryTimeout );
808
+ this .queryTimeout (Duration .ofSeconds (to ));
809
+ }
722
810
723
811
return new ClientConfig (this );
724
812
}
@@ -761,7 +849,11 @@ private ClientConfig(@Nonnull final Builder builder) {
761
849
gzipThreshold = builder .gzipThreshold != null ? builder .gzipThreshold : WriteOptions .DEFAULT_GZIP_THRESHOLD ;
762
850
writeNoSync = builder .writeNoSync != null ? builder .writeNoSync : WriteOptions .DEFAULT_NO_SYNC ;
763
851
defaultTags = builder .defaultTags ;
764
- timeout = builder .timeout != null ? builder .timeout : Duration .ofSeconds (10 );
852
+ timeout = builder .timeout != null ? builder .timeout : Duration .ofSeconds (WriteOptions .DEFAULT_WRITE_TIMEOUT );
853
+ writeTimeout = builder .writeTimeout != null
854
+ ? builder .writeTimeout : builder .timeout != null
855
+ ? builder .timeout : Duration .ofSeconds (WriteOptions .DEFAULT_WRITE_TIMEOUT );
856
+ queryTimeout = builder .queryTimeout ;
765
857
allowHttpRedirects = builder .allowHttpRedirects != null ? builder .allowHttpRedirects : false ;
766
858
disableServerCertificateValidation = builder .disableServerCertificateValidation != null
767
859
? builder .disableServerCertificateValidation : false ;
0 commit comments