36
36
import org .neo4j .driver .internal .async .pool .PoolSettings ;
37
37
import org .neo4j .driver .internal .cluster .RoutingSettings ;
38
38
import org .neo4j .driver .internal .handlers .pulln .FetchSizeUtil ;
39
- import org .neo4j .driver .internal .retry .RetrySettings ;
39
+ import org .neo4j .driver .internal .retry .ExponentialBackoffRetryLogic ;
40
40
import org .neo4j .driver .net .ServerAddressResolver ;
41
41
import org .neo4j .driver .util .Experimental ;
42
42
import org .neo4j .driver .util .Immutable ;
@@ -75,7 +75,9 @@ public final class Config implements Serializable {
75
75
76
76
private static final Config EMPTY = builder ().build ();
77
77
78
- /** User defined logging */
78
+ /**
79
+ * User defined logging
80
+ */
79
81
private final Logging logging ;
80
82
81
83
private final boolean logLeakedSessions ;
@@ -90,9 +92,9 @@ public final class Config implements Serializable {
90
92
91
93
private final long fetchSize ;
92
94
private final long routingTablePurgeDelayMillis ;
95
+ private final long maxTransactionRetryTimeMillis ;
93
96
94
97
private final int connectionTimeoutMillis ;
95
- private final RetrySettings retrySettings ;
96
98
private final ServerAddressResolver resolver ;
97
99
98
100
private final int eventLoopThreads ;
@@ -113,7 +115,7 @@ private Config(ConfigBuilder builder) {
113
115
114
116
this .connectionTimeoutMillis = builder .connectionTimeoutMillis ;
115
117
this .routingTablePurgeDelayMillis = builder .routingTablePurgeDelayMillis ;
116
- this .retrySettings = builder .retrySettings ;
118
+ this .maxTransactionRetryTimeMillis = builder .maxTransactionRetryTimeMillis ;
117
119
this .resolver = builder .resolver ;
118
120
this .fetchSize = builder .fetchSize ;
119
121
@@ -123,6 +125,7 @@ private Config(ConfigBuilder builder) {
123
125
124
126
/**
125
127
* Logging provider
128
+ *
126
129
* @return the Logging provider to use
127
130
*/
128
131
public Logging logging () {
@@ -212,18 +215,21 @@ public static Config defaultConfig() {
212
215
}
213
216
214
217
/**
215
- * @return the security setting to use when creating connections.
218
+ * Returns stale routing table purge delay.
219
+ *
220
+ * @return routing table purge delay
216
221
*/
217
- SecuritySettings securitySettings () {
218
- return securitySettings ;
222
+ public long routingTablePurgeDelayMillis () {
223
+ return routingTablePurgeDelayMillis ;
219
224
}
220
225
221
- RoutingSettings routingSettings () {
222
- return new RoutingSettings (routingTablePurgeDelayMillis );
223
- }
224
-
225
- RetrySettings retrySettings () {
226
- return retrySettings ;
226
+ /**
227
+ * Returns managed transactions maximum retry time.
228
+ *
229
+ * @return maximum retry time
230
+ */
231
+ public long maxTransactionRetryTimeMillis () {
232
+ return maxTransactionRetryTimeMillis ;
227
233
}
228
234
229
235
public long fetchSize () {
@@ -265,9 +271,9 @@ public static final class ConfigBuilder {
265
271
private String userAgent = format ("neo4j-java/%s" , driverVersion ());
266
272
private final SecuritySettings .SecuritySettingsBuilder securitySettingsBuilder =
267
273
new SecuritySettings .SecuritySettingsBuilder ();
268
- private long routingTablePurgeDelayMillis = RoutingSettings .DEFAULT . routingTablePurgeDelayMs () ;
274
+ private long routingTablePurgeDelayMillis = RoutingSettings .STALE_ROUTING_TABLE_PURGE_DELAY_MS ;
269
275
private int connectionTimeoutMillis = (int ) TimeUnit .SECONDS .toMillis (30 );
270
- private RetrySettings retrySettings = RetrySettings . DEFAULT ;
276
+ private long maxTransactionRetryTimeMillis = ExponentialBackoffRetryLogic . DEFAULT_MAX_RETRY_TIME_MS ;
271
277
private ServerAddressResolver resolver ;
272
278
private MetricsAdapter metricsAdapter = MetricsAdapter .DEV_NULL ;
273
279
private long fetchSize = FetchSizeUtil .DEFAULT_FETCH_SIZE ;
@@ -331,7 +337,7 @@ public ConfigBuilder withLeakedSessionsLogging() {
331
337
* validity and negative values mean connections will never be tested.
332
338
*
333
339
* @param value the minimum idle time
334
- * @param unit the unit in which the duration is given
340
+ * @param unit the unit in which the duration is given
335
341
* @return this builder
336
342
*/
337
343
public ConfigBuilder withConnectionLivenessCheckTimeout (long value , TimeUnit unit ) {
@@ -356,7 +362,7 @@ public ConfigBuilder withConnectionLivenessCheckTimeout(long value, TimeUnit uni
356
362
* checked.
357
363
*
358
364
* @param value the maximum connection lifetime
359
- * @param unit the unit in which the duration is given
365
+ * @param unit the unit in which the duration is given
360
366
* @return this builder
361
367
*/
362
368
public ConfigBuilder withMaxConnectionLifetime (long value , TimeUnit unit ) {
@@ -402,7 +408,7 @@ public ConfigBuilder withMaxConnectionPoolSize(int value) {
402
408
* of {@code 0} is allowed and results in no timeout and immediate failure when connection is unavailable.
403
409
*
404
410
* @param value the acquisition timeout
405
- * @param unit the unit in which the duration is given
411
+ * @param unit the unit in which the duration is given
406
412
* @return this builder
407
413
* @see #withMaxConnectionPoolSize(int)
408
414
*/
@@ -418,6 +424,7 @@ public ConfigBuilder withConnectionAcquisitionTimeout(long value, TimeUnit unit)
418
424
419
425
/**
420
426
* Set to use encrypted traffic.
427
+ *
421
428
* @return this builder
422
429
*/
423
430
public ConfigBuilder withEncryption () {
@@ -427,6 +434,7 @@ public ConfigBuilder withEncryption() {
427
434
428
435
/**
429
436
* Set to use unencrypted traffic.
437
+ *
430
438
* @return this builder
431
439
*/
432
440
public ConfigBuilder withoutEncryption () {
@@ -461,13 +469,12 @@ public ConfigBuilder withTrustStrategy(TrustStrategy trustStrategy) {
461
469
* The routing table of a database get refreshed if the database is used frequently.
462
470
* If the database is not used for a long time,
463
471
* the driver use the timeout specified here to purge the stale routing table.
464
- *
472
+ * <p>
465
473
* After a routing table is removed, next time when using the database of the purged routing table,
466
474
* the driver will fall back to use seed URI for a new routing table.
467
- * @param delay
468
- * the amount of time to wait before purging routing tables
469
- * @param unit
470
- * the unit in which the duration is given
475
+ *
476
+ * @param delay the amount of time to wait before purging routing tables
477
+ * @param unit the unit in which the duration is given
471
478
* @return this builder
472
479
*/
473
480
public ConfigBuilder withRoutingTablePurgeDelay (long delay , TimeUnit unit ) {
@@ -483,15 +490,16 @@ public ConfigBuilder withRoutingTablePurgeDelay(long delay, TimeUnit unit) {
483
490
/**
484
491
* Specify how many records to fetch in each batch.
485
492
* This config is only valid when the driver is used with servers that support Bolt V4 (Server version 4.0 and later).
486
- *
493
+ * <p>
487
494
* Bolt V4 enables pulling records in batches to allow client to take control of data population and apply back pressure to server.
488
495
* This config specifies the default fetch size for all query runs using {@link Session} and {@link org.neo4j.driver.async.AsyncSession}.
489
496
* By default, the value is set to {@code 1000}.
490
497
* Use {@code -1} to disables back pressure and config client to pull all records at once after each run.
491
- *
498
+ * <p>
492
499
* This config only applies to run result obtained via {@link Session} and {@link org.neo4j.driver.async.AsyncSession}.
493
500
* As with {@link org.neo4j.driver.reactive.RxSession}, the batch size is provided via
494
501
* {@link org.reactivestreams.Subscription#request(long)} instead.
502
+ *
495
503
* @param size the default record fetch size when pulling records in batches using Bolt V4.
496
504
* @return this builder
497
505
*/
@@ -512,10 +520,10 @@ public ConfigBuilder withFetchSize(long size) {
512
520
* The default value of this parameter is {@code 30 SECONDS}.
513
521
*
514
522
* @param value the timeout duration
515
- * @param unit the unit in which duration is given
523
+ * @param unit the unit in which duration is given
516
524
* @return this builder
517
525
* @throws IllegalArgumentException when given value is negative or does not fit in {@code int} when
518
- * converted to milliseconds.
526
+ * converted to milliseconds.
519
527
*/
520
528
public ConfigBuilder withConnectionTimeout (long value , TimeUnit unit ) {
521
529
long connectionTimeoutMillis = unit .toMillis (value );
@@ -534,16 +542,14 @@ public ConfigBuilder withConnectionTimeout(long value, TimeUnit unit) {
534
542
}
535
543
536
544
/**
537
- * Specify the maximum time transactions are allowed to retry via
538
- * {@link Session#readTransaction(TransactionWork)} and {@link Session#writeTransaction(TransactionWork)}
539
- * methods. These methods will retry the given unit of work on {@link org.neo4j.driver.exceptions.ServiceUnavailableException},
540
- * {@link org.neo4j.driver.exceptions.SessionExpiredException} and {@link org.neo4j.driver.exceptions.TransientException} with
541
- * exponential backoff using initial delay of 1 second.
545
+ * Specify the maximum time managed transactions are allowed to retry.
546
+ * <p>
547
+ * Managed transactions are available via methods like {@link Session#executeRead(TransactionCallback)}, {@link Session#executeWrite(TransactionCallback, TransactionConfig)} and some other variations available under similar naming.
542
548
* <p>
543
549
* Default value is 30 seconds.
544
550
*
545
551
* @param value the timeout duration
546
- * @param unit the unit in which duration is given
552
+ * @param unit the unit in which duration is given
547
553
* @return this builder
548
554
* @throws IllegalArgumentException when given value is negative
549
555
*/
@@ -553,7 +559,7 @@ public ConfigBuilder withMaxTransactionRetryTime(long value, TimeUnit unit) {
553
559
throw new IllegalArgumentException (
554
560
String .format ("The max retry time may not be smaller than 0, but was %d %s." , value , unit ));
555
561
}
556
- this .retrySettings = new RetrySettings ( maxRetryTimeMs ) ;
562
+ this .maxTransactionRetryTimeMillis = maxRetryTimeMs ;
557
563
return this ;
558
564
}
559
565
@@ -586,6 +592,7 @@ public ConfigBuilder withDriverMetrics() {
586
592
587
593
/**
588
594
* Disable driver metrics. When disabled, driver metrics cannot be accessed via {@link Driver#metrics()}.
595
+ *
589
596
* @return this builder.
590
597
*/
591
598
public ConfigBuilder withoutDriverMetrics () {
@@ -619,6 +626,7 @@ public ConfigBuilder withMetricsAdapter(MetricsAdapter metricsAdapter) {
619
626
/**
620
627
* Configure the event loop thread count. This specifies how many threads the driver can use to handle network I/O events
621
628
* and user's events in driver's I/O threads. By default, 2 * NumberOfProcessors amount of threads will be used instead.
629
+ *
622
630
* @param size the thread count.
623
631
* @return this builder.
624
632
* @throws IllegalArgumentException if the value of the size is set to a number that is less than 1.
@@ -634,6 +642,7 @@ public ConfigBuilder withEventLoopThreads(int size) {
634
642
635
643
/**
636
644
* Configure the user_agent field sent to the server to identify the connected client.
645
+ *
637
646
* @param userAgent the string to configure user_agent.
638
647
* @return this builder.
639
648
*/
@@ -802,6 +811,7 @@ public static TrustStrategy trustAllCertificates() {
802
811
803
812
/**
804
813
* The revocation strategy used for verifying certificates.
814
+ *
805
815
* @return this {@link TrustStrategy}'s revocation strategy
806
816
*/
807
817
public RevocationCheckingStrategy revocationCheckingStrategy () {
@@ -811,6 +821,7 @@ public RevocationCheckingStrategy revocationCheckingStrategy() {
811
821
/**
812
822
* Configures the {@link TrustStrategy} to not carry out OCSP revocation checks on certificates. This is the
813
823
* option that is configured by default.
824
+ *
814
825
* @return the current trust strategy
815
826
*/
816
827
public TrustStrategy withoutCertificateRevocationChecks () {
@@ -823,6 +834,7 @@ public TrustStrategy withoutCertificateRevocationChecks() {
823
834
* stapled to the certificate. If no stapled response is found, then certificate verification continues
824
835
* (and does not fail verification). This setting also requires the server to be configured to enable
825
836
* OCSP stapling.
837
+ *
826
838
* @return the current trust strategy
827
839
*/
828
840
public TrustStrategy withVerifyIfPresentRevocationChecks () {
@@ -834,9 +846,10 @@ public TrustStrategy withVerifyIfPresentRevocationChecks() {
834
846
* Configures the {@link TrustStrategy} to carry out strict OCSP revocation checks for revocation status that
835
847
* are stapled to the certificate. If no stapled response is found, then the driver will fail certificate verification
836
848
* and not connect to the server. This setting also requires the server to be configured to enable OCSP stapling.
837
- *
849
+ * <p>
838
850
* Note: enabling this setting will prevent the driver connecting to the server when the server is unable to reach
839
851
* the certificate's configured OCSP responder URL.
852
+ *
840
853
* @return the current trust strategy
841
854
*/
842
855
public TrustStrategy withStrictRevocationChecks () {
0 commit comments