Skip to content

Commit 55f602f

Browse files
committed
Update
1 parent d4ea9c7 commit 55f602f

File tree

3 files changed

+54
-33
lines changed

3 files changed

+54
-33
lines changed

driver/src/main/java/org/neo4j/driver/Config.java

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ public final class Config implements Serializable {
7575

7676
private static final Config EMPTY = builder().build();
7777

78-
/** User defined logging */
78+
/**
79+
* User defined logging
80+
*/
7981
private final Logging logging;
8082

8183
private final boolean logLeakedSessions;
@@ -90,9 +92,9 @@ public final class Config implements Serializable {
9092

9193
private final long fetchSize;
9294
private final long routingTablePurgeDelayMillis;
95+
private final long maxTransactionRetryTimeMillis;
9396

9497
private final int connectionTimeoutMillis;
95-
private final long maxTransactionRetryTime;
9698
private final ServerAddressResolver resolver;
9799

98100
private final int eventLoopThreads;
@@ -113,7 +115,7 @@ private Config(ConfigBuilder builder) {
113115

114116
this.connectionTimeoutMillis = builder.connectionTimeoutMillis;
115117
this.routingTablePurgeDelayMillis = builder.routingTablePurgeDelayMillis;
116-
this.maxTransactionRetryTime = builder.maxTransactionRetryTime;
118+
this.maxTransactionRetryTimeMillis = builder.maxTransactionRetryTimeMillis;
117119
this.resolver = builder.resolver;
118120
this.fetchSize = builder.fetchSize;
119121

@@ -123,6 +125,7 @@ private Config(ConfigBuilder builder) {
123125

124126
/**
125127
* Logging provider
128+
*
126129
* @return the Logging provider to use
127130
*/
128131
public Logging logging() {
@@ -211,12 +214,22 @@ public static Config defaultConfig() {
211214
return EMPTY;
212215
}
213216

214-
public long routingTablePurgeDelay() {
217+
/**
218+
* Returns stale routing table purge delay.
219+
*
220+
* @return routing table purge delay
221+
*/
222+
public long routingTablePurgeDelayMillis() {
215223
return routingTablePurgeDelayMillis;
216224
}
217225

218-
public long maxTransactionRetryTime() {
219-
return maxTransactionRetryTime;
226+
/**
227+
* Returns managed transactions maximum retry time.
228+
*
229+
* @return maximum retry time
230+
*/
231+
public long maxTransactionRetryTimeMillis() {
232+
return maxTransactionRetryTimeMillis;
220233
}
221234

222235
public long fetchSize() {
@@ -260,7 +273,7 @@ public static final class ConfigBuilder {
260273
new SecuritySettings.SecuritySettingsBuilder();
261274
private long routingTablePurgeDelayMillis = RoutingSettings.STALE_ROUTING_TABLE_PURGE_DELAY_MS;
262275
private int connectionTimeoutMillis = (int) TimeUnit.SECONDS.toMillis(30);
263-
private long maxTransactionRetryTime = ExponentialBackoffRetryLogic.DEFAULT_MAX_RETRY_TIME_MS;
276+
private long maxTransactionRetryTimeMillis = ExponentialBackoffRetryLogic.DEFAULT_MAX_RETRY_TIME_MS;
264277
private ServerAddressResolver resolver;
265278
private MetricsAdapter metricsAdapter = MetricsAdapter.DEV_NULL;
266279
private long fetchSize = FetchSizeUtil.DEFAULT_FETCH_SIZE;
@@ -324,7 +337,7 @@ public ConfigBuilder withLeakedSessionsLogging() {
324337
* validity and negative values mean connections will never be tested.
325338
*
326339
* @param value the minimum idle time
327-
* @param unit the unit in which the duration is given
340+
* @param unit the unit in which the duration is given
328341
* @return this builder
329342
*/
330343
public ConfigBuilder withConnectionLivenessCheckTimeout(long value, TimeUnit unit) {
@@ -349,7 +362,7 @@ public ConfigBuilder withConnectionLivenessCheckTimeout(long value, TimeUnit uni
349362
* checked.
350363
*
351364
* @param value the maximum connection lifetime
352-
* @param unit the unit in which the duration is given
365+
* @param unit the unit in which the duration is given
353366
* @return this builder
354367
*/
355368
public ConfigBuilder withMaxConnectionLifetime(long value, TimeUnit unit) {
@@ -395,7 +408,7 @@ public ConfigBuilder withMaxConnectionPoolSize(int value) {
395408
* of {@code 0} is allowed and results in no timeout and immediate failure when connection is unavailable.
396409
*
397410
* @param value the acquisition timeout
398-
* @param unit the unit in which the duration is given
411+
* @param unit the unit in which the duration is given
399412
* @return this builder
400413
* @see #withMaxConnectionPoolSize(int)
401414
*/
@@ -411,6 +424,7 @@ public ConfigBuilder withConnectionAcquisitionTimeout(long value, TimeUnit unit)
411424

412425
/**
413426
* Set to use encrypted traffic.
427+
*
414428
* @return this builder
415429
*/
416430
public ConfigBuilder withEncryption() {
@@ -420,6 +434,7 @@ public ConfigBuilder withEncryption() {
420434

421435
/**
422436
* Set to use unencrypted traffic.
437+
*
423438
* @return this builder
424439
*/
425440
public ConfigBuilder withoutEncryption() {
@@ -454,13 +469,12 @@ public ConfigBuilder withTrustStrategy(TrustStrategy trustStrategy) {
454469
* The routing table of a database get refreshed if the database is used frequently.
455470
* If the database is not used for a long time,
456471
* the driver use the timeout specified here to purge the stale routing table.
457-
*
472+
* <p>
458473
* After a routing table is removed, next time when using the database of the purged routing table,
459474
* the driver will fall back to use seed URI for a new routing table.
460-
* @param delay
461-
* the amount of time to wait before purging routing tables
462-
* @param unit
463-
* 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
464478
* @return this builder
465479
*/
466480
public ConfigBuilder withRoutingTablePurgeDelay(long delay, TimeUnit unit) {
@@ -476,15 +490,16 @@ public ConfigBuilder withRoutingTablePurgeDelay(long delay, TimeUnit unit) {
476490
/**
477491
* Specify how many records to fetch in each batch.
478492
* This config is only valid when the driver is used with servers that support Bolt V4 (Server version 4.0 and later).
479-
*
493+
* <p>
480494
* Bolt V4 enables pulling records in batches to allow client to take control of data population and apply back pressure to server.
481495
* This config specifies the default fetch size for all query runs using {@link Session} and {@link org.neo4j.driver.async.AsyncSession}.
482496
* By default, the value is set to {@code 1000}.
483497
* Use {@code -1} to disables back pressure and config client to pull all records at once after each run.
484-
*
498+
* <p>
485499
* This config only applies to run result obtained via {@link Session} and {@link org.neo4j.driver.async.AsyncSession}.
486500
* As with {@link org.neo4j.driver.reactive.RxSession}, the batch size is provided via
487501
* {@link org.reactivestreams.Subscription#request(long)} instead.
502+
*
488503
* @param size the default record fetch size when pulling records in batches using Bolt V4.
489504
* @return this builder
490505
*/
@@ -505,10 +520,10 @@ public ConfigBuilder withFetchSize(long size) {
505520
* The default value of this parameter is {@code 30 SECONDS}.
506521
*
507522
* @param value the timeout duration
508-
* @param unit the unit in which duration is given
523+
* @param unit the unit in which duration is given
509524
* @return this builder
510525
* @throws IllegalArgumentException when given value is negative or does not fit in {@code int} when
511-
* converted to milliseconds.
526+
* converted to milliseconds.
512527
*/
513528
public ConfigBuilder withConnectionTimeout(long value, TimeUnit unit) {
514529
long connectionTimeoutMillis = unit.toMillis(value);
@@ -527,16 +542,14 @@ public ConfigBuilder withConnectionTimeout(long value, TimeUnit unit) {
527542
}
528543

529544
/**
530-
* Specify the maximum time transactions are allowed to retry via
531-
* {@link Session#readTransaction(TransactionWork)} and {@link Session#writeTransaction(TransactionWork)}
532-
* methods. These methods will retry the given unit of work on {@link org.neo4j.driver.exceptions.ServiceUnavailableException},
533-
* {@link org.neo4j.driver.exceptions.SessionExpiredException} and {@link org.neo4j.driver.exceptions.TransientException} with
534-
* 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.
535548
* <p>
536549
* Default value is 30 seconds.
537550
*
538551
* @param value the timeout duration
539-
* @param unit the unit in which duration is given
552+
* @param unit the unit in which duration is given
540553
* @return this builder
541554
* @throws IllegalArgumentException when given value is negative
542555
*/
@@ -546,7 +559,7 @@ public ConfigBuilder withMaxTransactionRetryTime(long value, TimeUnit unit) {
546559
throw new IllegalArgumentException(
547560
String.format("The max retry time may not be smaller than 0, but was %d %s.", value, unit));
548561
}
549-
this.maxTransactionRetryTime = maxRetryTimeMs;
562+
this.maxTransactionRetryTimeMillis = maxRetryTimeMs;
550563
return this;
551564
}
552565

@@ -579,6 +592,7 @@ public ConfigBuilder withDriverMetrics() {
579592

580593
/**
581594
* Disable driver metrics. When disabled, driver metrics cannot be accessed via {@link Driver#metrics()}.
595+
*
582596
* @return this builder.
583597
*/
584598
public ConfigBuilder withoutDriverMetrics() {
@@ -612,6 +626,7 @@ public ConfigBuilder withMetricsAdapter(MetricsAdapter metricsAdapter) {
612626
/**
613627
* Configure the event loop thread count. This specifies how many threads the driver can use to handle network I/O events
614628
* and user's events in driver's I/O threads. By default, 2 * NumberOfProcessors amount of threads will be used instead.
629+
*
615630
* @param size the thread count.
616631
* @return this builder.
617632
* @throws IllegalArgumentException if the value of the size is set to a number that is less than 1.
@@ -627,6 +642,7 @@ public ConfigBuilder withEventLoopThreads(int size) {
627642

628643
/**
629644
* Configure the user_agent field sent to the server to identify the connected client.
645+
*
630646
* @param userAgent the string to configure user_agent.
631647
* @return this builder.
632648
*/
@@ -795,6 +811,7 @@ public static TrustStrategy trustAllCertificates() {
795811

796812
/**
797813
* The revocation strategy used for verifying certificates.
814+
*
798815
* @return this {@link TrustStrategy}'s revocation strategy
799816
*/
800817
public RevocationCheckingStrategy revocationCheckingStrategy() {
@@ -804,6 +821,7 @@ public RevocationCheckingStrategy revocationCheckingStrategy() {
804821
/**
805822
* Configures the {@link TrustStrategy} to not carry out OCSP revocation checks on certificates. This is the
806823
* option that is configured by default.
824+
*
807825
* @return the current trust strategy
808826
*/
809827
public TrustStrategy withoutCertificateRevocationChecks() {
@@ -816,6 +834,7 @@ public TrustStrategy withoutCertificateRevocationChecks() {
816834
* stapled to the certificate. If no stapled response is found, then certificate verification continues
817835
* (and does not fail verification). This setting also requires the server to be configured to enable
818836
* OCSP stapling.
837+
*
819838
* @return the current trust strategy
820839
*/
821840
public TrustStrategy withVerifyIfPresentRevocationChecks() {
@@ -827,9 +846,10 @@ public TrustStrategy withVerifyIfPresentRevocationChecks() {
827846
* Configures the {@link TrustStrategy} to carry out strict OCSP revocation checks for revocation status that
828847
* are stapled to the certificate. If no stapled response is found, then the driver will fail certificate verification
829848
* and not connect to the server. This setting also requires the server to be configured to enable OCSP stapling.
830-
*
849+
* <p>
831850
* Note: enabling this setting will prevent the driver connecting to the server when the server is unable to reach
832851
* the certificate's configured OCSP responder URL.
852+
*
833853
* @return the current trust strategy
834854
*/
835855
public TrustStrategy withStrictRevocationChecks() {

driver/src/main/java/org/neo4j/driver/internal/DriverFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,13 @@ public final Driver newInstance(
9797
authToken = authToken == null ? AuthTokens.none() : authToken;
9898

9999
BoltServerAddress address = new BoltServerAddress(uri);
100-
RoutingSettings routingSettings = new RoutingSettings(config.routingTablePurgeDelay(), new RoutingContext(uri));
100+
RoutingSettings routingSettings =
101+
new RoutingSettings(config.routingTablePurgeDelayMillis(), new RoutingContext(uri));
101102

102103
InternalLoggerFactory.setDefaultFactory(new NettyLogging(config.logging()));
103104
EventExecutorGroup eventExecutorGroup = bootstrap.config().group();
104105
RetryLogic retryLogic =
105-
createRetryLogic(config.maxTransactionRetryTime(), eventExecutorGroup, config.logging());
106+
createRetryLogic(config.maxTransactionRetryTimeMillis(), eventExecutorGroup, config.logging());
106107

107108
MetricsProvider metricsProvider = getOrCreateMetricsProvider(config, createClock());
108109
ConnectionPool connectionPool = createConnectionPool(

driver/src/test/java/org/neo4j/driver/ConfigTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void shouldAllowZeroMaxRetryTimeMs() {
195195
.withMaxTransactionRetryTime(0, TimeUnit.SECONDS)
196196
.build();
197197

198-
assertEquals(0, config.maxTransactionRetryTime());
198+
assertEquals(0, config.maxTransactionRetryTimeMillis());
199199
}
200200

201201
@Test
@@ -204,7 +204,7 @@ void shouldAllowPositiveRetryAttempts() {
204204
.withMaxTransactionRetryTime(42, TimeUnit.SECONDS)
205205
.build();
206206

207-
assertEquals(TimeUnit.SECONDS.toMillis(42), config.maxTransactionRetryTime());
207+
assertEquals(TimeUnit.SECONDS.toMillis(42), config.maxTransactionRetryTimeMillis());
208208
}
209209

210210
@Test
@@ -413,7 +413,7 @@ void shouldSerialize() throws Exception {
413413
assertEquals(config.idleTimeBeforeConnectionTest(), verify.idleTimeBeforeConnectionTest());
414414
assertEquals(config.maxConnectionLifetimeMillis(), verify.maxConnectionLifetimeMillis());
415415
assertSame(DevNullLogging.DEV_NULL_LOGGING, verify.logging());
416-
assertEquals(config.maxTransactionRetryTime(), verify.maxTransactionRetryTime());
416+
assertEquals(config.maxTransactionRetryTimeMillis(), verify.maxTransactionRetryTimeMillis());
417417
assertEquals(config.fetchSize(), verify.fetchSize());
418418
assertEquals(config.eventLoopThreads(), verify.eventLoopThreads());
419419
assertEquals(config.encrypted(), verify.encrypted());
@@ -430,7 +430,7 @@ void shouldSerialize() throws Exception {
430430
assertEquals(config.userAgent(), verify.userAgent());
431431
assertEquals(config.isMetricsEnabled(), verify.isMetricsEnabled());
432432
assertEquals(config.metricsAdapter(), verify.metricsAdapter());
433-
assertEquals(config.maxTransactionRetryTime(), verify.maxTransactionRetryTime());
433+
assertEquals(config.maxTransactionRetryTimeMillis(), verify.maxTransactionRetryTimeMillis());
434434
assertEquals(config.logLeakedSessions(), verify.logLeakedSessions());
435435
}
436436

0 commit comments

Comments
 (0)