20
20
import static org .neo4j .driver .internal .logging .DevNullLogging .DEV_NULL_LOGGING ;
21
21
import static org .neo4j .driver .internal .util .DriverInfoUtil .driverVersion ;
22
22
23
+ import io .netty .channel .EventLoop ;
23
24
import java .io .File ;
24
25
import java .io .Serial ;
25
26
import java .io .Serializable ;
28
29
import java .util .Collections ;
29
30
import java .util .List ;
30
31
import java .util .Objects ;
32
+ import java .util .Optional ;
33
+ import java .util .Set ;
31
34
import java .util .concurrent .TimeUnit ;
32
35
import java .util .logging .Level ;
36
+ import java .util .stream .Collectors ;
37
+ import org .neo4j .driver .async .AsyncSession ;
33
38
import org .neo4j .driver .exceptions .UnsupportedFeatureException ;
39
+ import org .neo4j .driver .internal .InternalNotificationConfig ;
34
40
import org .neo4j .driver .internal .SecuritySettings ;
35
41
import org .neo4j .driver .internal .async .pool .PoolSettings ;
36
42
import org .neo4j .driver .internal .cluster .RoutingSettings ;
39
45
import org .neo4j .driver .net .ServerAddressResolver ;
40
46
import org .neo4j .driver .util .Experimental ;
41
47
import org .neo4j .driver .util .Immutable ;
48
+ import org .neo4j .driver .util .Resource ;
42
49
43
50
/**
44
51
* A configuration class to config driver properties.
@@ -223,6 +230,7 @@ public int connectionTimeoutMillis() {
223
230
224
231
/**
225
232
* Returns the maximum connection pool size.
233
+ *
226
234
* @return the maximum size
227
235
*/
228
236
public int maxConnectionPoolSize () {
@@ -231,6 +239,7 @@ public int maxConnectionPoolSize() {
231
239
232
240
/**
233
241
* Returns the connection acquisition timeout in milliseconds.
242
+ *
234
243
* @return the acquisition timeout
235
244
*/
236
245
public long connectionAcquisitionTimeoutMillis () {
@@ -296,6 +305,7 @@ public long maxTransactionRetryTimeMillis() {
296
305
297
306
/**
298
307
* Returns the fetch size.
308
+ *
299
309
* @return the fetch size
300
310
*/
301
311
public long fetchSize () {
@@ -304,6 +314,7 @@ public long fetchSize() {
304
314
305
315
/**
306
316
* Returns notification config.
317
+ *
307
318
* @return the notification config
308
319
* @since 5.7
309
320
*/
@@ -312,7 +323,30 @@ public NotificationConfig notificationConfig() {
312
323
}
313
324
314
325
/**
315
- * Returns the number of {@link io.netty.channel.EventLoop} threads.
326
+ * TODO
327
+ *
328
+ * @return TODO
329
+ * @since 5.22.0
330
+ */
331
+ public Optional <NotificationSeverity > minimumNotificationSeverity () {
332
+ return Optional .ofNullable (((InternalNotificationConfig ) notificationConfig ).minimumSeverity ());
333
+ }
334
+
335
+ /**
336
+ * TODO
337
+ * @return TODO
338
+ * @since 5.22.0
339
+ */
340
+ public Set <NotificationClassification > disabledNotificationClassifications () {
341
+ return ((InternalNotificationConfig ) notificationConfig )
342
+ .disabledCategories ().stream ()
343
+ .map (NotificationClassification .class ::cast )
344
+ .collect (Collectors .toUnmodifiableSet ());
345
+ }
346
+
347
+ /**
348
+ * Returns the number of {@link EventLoop} threads.
349
+ *
316
350
* @return the number of threads
317
351
*/
318
352
public int eventLoopThreads () {
@@ -328,6 +362,7 @@ public boolean isMetricsEnabled() {
328
362
329
363
/**
330
364
* Returns the {@link MetricsAdapter}.
365
+ *
331
366
* @return the metrics adapter
332
367
*/
333
368
public MetricsAdapter metricsAdapter () {
@@ -399,7 +434,7 @@ public ConfigBuilder withLogging(Logging logging) {
399
434
* Enable logging of leaked sessions.
400
435
* <p>
401
436
* Each {@link Session session} is associated with a network connection and thus is a
402
- * {@link org.neo4j.driver.util. Resource resource} that needs to be explicitly closed.
437
+ * {@link Resource resource} that needs to be explicitly closed.
403
438
* Unclosed sessions will result in socket leaks and could cause {@link OutOfMemoryError}s.
404
439
* <p>
405
440
* Session is considered to be leaked when it is finalized via {@link Object#finalize()} while not being
@@ -579,8 +614,8 @@ public ConfigBuilder withTrustStrategy(TrustStrategy trustStrategy) {
579
614
public ConfigBuilder withRoutingTablePurgeDelay (long delay , TimeUnit unit ) {
580
615
var routingTablePurgeDelayMillis = unit .toMillis (delay );
581
616
if (routingTablePurgeDelayMillis < 0 ) {
582
- throw new IllegalArgumentException (String . format (
583
- "The routing table purge delay may not be smaller than 0, but was %d %s." , delay , unit ));
617
+ throw new IllegalArgumentException (
618
+ format ( "The routing table purge delay may not be smaller than 0, but was %d %s." , delay , unit ));
584
619
}
585
620
this .routingTablePurgeDelayMillis = routingTablePurgeDelayMillis ;
586
621
return this ;
@@ -591,11 +626,11 @@ public ConfigBuilder withRoutingTablePurgeDelay(long delay, TimeUnit unit) {
591
626
* This config is only valid when the driver is used with servers that support Bolt V4 (Server version 4.0 and later).
592
627
* <p>
593
628
* Bolt V4 enables pulling records in batches to allow client to take control of data population and apply back pressure to server.
594
- * This config specifies the default fetch size for all query runs using {@link Session} and {@link org.neo4j.driver.async. AsyncSession}.
629
+ * This config specifies the default fetch size for all query runs using {@link Session} and {@link AsyncSession}.
595
630
* By default, the value is set to {@code 1000}.
596
631
* Use {@code -1} to disables back pressure and config client to pull all records at once after each run.
597
632
* <p>
598
- * This config only applies to run results obtained via {@link Session} and {@link org.neo4j.driver.async. AsyncSession}.
633
+ * This config only applies to run results obtained via {@link Session} and {@link AsyncSession}.
599
634
* As with the reactive sessions the batch size is managed by the subscription requests instead.
600
635
*
601
636
* @param size the default record fetch size when pulling records in batches using Bolt V4.
@@ -627,11 +662,11 @@ public ConfigBuilder withConnectionTimeout(long value, TimeUnit unit) {
627
662
var connectionTimeoutMillis = unit .toMillis (value );
628
663
if (connectionTimeoutMillis < 0 ) {
629
664
throw new IllegalArgumentException (
630
- String . format ("The connection timeout may not be smaller than 0, but was %d %s." , value , unit ));
665
+ format ("The connection timeout may not be smaller than 0, but was %d %s." , value , unit ));
631
666
}
632
667
var connectionTimeoutMillisInt = (int ) connectionTimeoutMillis ;
633
668
if (connectionTimeoutMillisInt != connectionTimeoutMillis ) {
634
- throw new IllegalArgumentException (String . format (
669
+ throw new IllegalArgumentException (format (
635
670
"The connection timeout must represent int value when converted to milliseconds %d." ,
636
671
connectionTimeoutMillis ));
637
672
}
@@ -655,7 +690,7 @@ public ConfigBuilder withMaxTransactionRetryTime(long value, TimeUnit unit) {
655
690
var maxRetryTimeMs = unit .toMillis (value );
656
691
if (maxRetryTimeMs < 0 ) {
657
692
throw new IllegalArgumentException (
658
- String . format ("The max retry time may not be smaller than 0, but was %d %s." , value , unit ));
693
+ format ("The max retry time may not be smaller than 0, but was %d %s." , value , unit ));
659
694
}
660
695
this .maxTransactionRetryTimeMillis = maxRetryTimeMs ;
661
696
return this ;
@@ -732,7 +767,7 @@ public ConfigBuilder withMetricsAdapter(MetricsAdapter metricsAdapter) {
732
767
public ConfigBuilder withEventLoopThreads (int size ) {
733
768
if (size < 1 ) {
734
769
throw new IllegalArgumentException (
735
- String . format ("The event loop thread may not be smaller than 1, but was %d." , size ));
770
+ format ("The event loop thread may not be smaller than 1, but was %d." , size ));
736
771
}
737
772
this .eventLoopThreads = size ;
738
773
return this ;
@@ -768,6 +803,40 @@ public ConfigBuilder withNotificationConfig(NotificationConfig notificationConfi
768
803
return this ;
769
804
}
770
805
806
+ /**
807
+ * TODO
808
+ *
809
+ * @param minimumNotificationSeverity TODO
810
+ * @return TODO
811
+ * @since 5.22.0
812
+ */
813
+ public ConfigBuilder withMinimumNotificationSeverity (NotificationSeverity minimumNotificationSeverity ) {
814
+ if (minimumNotificationSeverity == null ) {
815
+ notificationConfig = NotificationConfig .disableAllConfig ();
816
+ } else {
817
+ notificationConfig = notificationConfig .enableMinimumSeverity (minimumNotificationSeverity );
818
+ }
819
+ return this ;
820
+ }
821
+
822
+ /**
823
+ * TODO
824
+ *
825
+ * @param disabledNotificationClassifications TODO
826
+ * @return TODO
827
+ * @since 5.22.0
828
+ */
829
+ public ConfigBuilder withDisabledNotificationClassifications (
830
+ Set <NotificationClassification > disabledNotificationClassifications ) {
831
+ var disabledCategories = disabledNotificationClassifications == null
832
+ ? Collections .<NotificationCategory >emptySet ()
833
+ : disabledNotificationClassifications .stream ()
834
+ .map (NotificationCategory .class ::cast )
835
+ .collect (Collectors .toSet ());
836
+ notificationConfig = notificationConfig .disableCategories (disabledCategories );
837
+ return this ;
838
+ }
839
+
771
840
/**
772
841
* Sets if telemetry is disabled on the driver side.
773
842
* <p>
0 commit comments