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 .RoutingSettings ;
35
41
import org .neo4j .driver .internal .SecuritySettings ;
36
42
import org .neo4j .driver .internal .retry .ExponentialBackoffRetryLogic ;
37
43
import org .neo4j .driver .net .ServerAddressResolver ;
38
44
import org .neo4j .driver .util .Experimental ;
39
45
import org .neo4j .driver .util .Immutable ;
46
+ import org .neo4j .driver .util .Preview ;
47
+ import org .neo4j .driver .util .Resource ;
40
48
41
49
/**
42
50
* A configuration class to config driver properties.
@@ -221,6 +229,7 @@ public int connectionTimeoutMillis() {
221
229
222
230
/**
223
231
* Returns the maximum connection pool size.
232
+ *
224
233
* @return the maximum size
225
234
*/
226
235
public int maxConnectionPoolSize () {
@@ -229,6 +238,7 @@ public int maxConnectionPoolSize() {
229
238
230
239
/**
231
240
* Returns the connection acquisition timeout in milliseconds.
241
+ *
232
242
* @return the acquisition timeout
233
243
*/
234
244
public long connectionAcquisitionTimeoutMillis () {
@@ -294,6 +304,7 @@ public long maxTransactionRetryTimeMillis() {
294
304
295
305
/**
296
306
* Returns the fetch size.
307
+ *
297
308
* @return the fetch size
298
309
*/
299
310
public long fetchSize () {
@@ -302,6 +313,7 @@ public long fetchSize() {
302
313
303
314
/**
304
315
* Returns notification config.
316
+ *
305
317
* @return the notification config
306
318
* @since 5.7
307
319
*/
@@ -310,7 +322,35 @@ public NotificationConfig notificationConfig() {
310
322
}
311
323
312
324
/**
313
- * Returns the number of {@link io.netty.channel.EventLoop} threads.
325
+ * Returns a minimum notification severity.
326
+ *
327
+ * @return an {@link Optional} of minimum {@link NotificationSeverity} or an empty {@link Optional} if it is not set
328
+ * @since 5.22.0
329
+ */
330
+ @ Preview (name = "GQL-status object" )
331
+ public Optional <NotificationSeverity > minimumNotificationSeverity () {
332
+ return Optional .ofNullable (((InternalNotificationConfig ) notificationConfig ).minimumSeverity ());
333
+ }
334
+
335
+ /**
336
+ * Returns a set of disabled notification classifications.
337
+ * @return the {@link Set} of disabled {@link NotificationClassification}
338
+ * @since 5.22.0
339
+ */
340
+ @ Preview (name = "GQL-status object" )
341
+ public Set <NotificationClassification > disabledNotificationClassifications () {
342
+ var disabledCategories = ((InternalNotificationConfig ) notificationConfig ).disabledCategories ();
343
+ return disabledCategories != null
344
+ ? ((InternalNotificationConfig ) notificationConfig )
345
+ .disabledCategories ().stream ()
346
+ .map (NotificationClassification .class ::cast )
347
+ .collect (Collectors .toUnmodifiableSet ())
348
+ : Collections .emptySet ();
349
+ }
350
+
351
+ /**
352
+ * Returns the number of {@link EventLoop} threads.
353
+ *
314
354
* @return the number of threads
315
355
*/
316
356
public int eventLoopThreads () {
@@ -326,6 +366,7 @@ public boolean isMetricsEnabled() {
326
366
327
367
/**
328
368
* Returns the {@link MetricsAdapter}.
369
+ *
329
370
* @return the metrics adapter
330
371
*/
331
372
public MetricsAdapter metricsAdapter () {
@@ -371,6 +412,7 @@ public static final class ConfigBuilder {
371
412
private MetricsAdapter metricsAdapter = MetricsAdapter .DEV_NULL ;
372
413
private long fetchSize = 1000 ;
373
414
private int eventLoopThreads = 0 ;
415
+
374
416
private NotificationConfig notificationConfig = NotificationConfig .defaultConfig ();
375
417
376
418
private boolean telemetryDisabled = false ;
@@ -397,7 +439,7 @@ public ConfigBuilder withLogging(Logging logging) {
397
439
* Enable logging of leaked sessions.
398
440
* <p>
399
441
* Each {@link Session session} is associated with a network connection and thus is a
400
- * {@link org.neo4j.driver.util. Resource resource} that needs to be explicitly closed.
442
+ * {@link Resource resource} that needs to be explicitly closed.
401
443
* Unclosed sessions will result in socket leaks and could cause {@link OutOfMemoryError}s.
402
444
* <p>
403
445
* Session is considered to be leaked when it is finalized via {@link Object#finalize()} while not being
@@ -577,8 +619,8 @@ public ConfigBuilder withTrustStrategy(TrustStrategy trustStrategy) {
577
619
public ConfigBuilder withRoutingTablePurgeDelay (long delay , TimeUnit unit ) {
578
620
var routingTablePurgeDelayMillis = unit .toMillis (delay );
579
621
if (routingTablePurgeDelayMillis < 0 ) {
580
- throw new IllegalArgumentException (String . format (
581
- "The routing table purge delay may not be smaller than 0, but was %d %s." , delay , unit ));
622
+ throw new IllegalArgumentException (
623
+ format ( "The routing table purge delay may not be smaller than 0, but was %d %s." , delay , unit ));
582
624
}
583
625
this .routingTablePurgeDelayMillis = routingTablePurgeDelayMillis ;
584
626
return this ;
@@ -589,11 +631,11 @@ public ConfigBuilder withRoutingTablePurgeDelay(long delay, TimeUnit unit) {
589
631
* This config is only valid when the driver is used with servers that support Bolt V4 (Server version 4.0 and later).
590
632
* <p>
591
633
* Bolt V4 enables pulling records in batches to allow client to take control of data population and apply back pressure to server.
592
- * This config specifies the default fetch size for all query runs using {@link Session} and {@link org.neo4j.driver.async. AsyncSession}.
634
+ * This config specifies the default fetch size for all query runs using {@link Session} and {@link AsyncSession}.
593
635
* By default, the value is set to {@code 1000}.
594
636
* Use {@code -1} to disables back pressure and config client to pull all records at once after each run.
595
637
* <p>
596
- * This config only applies to run results obtained via {@link Session} and {@link org.neo4j.driver.async. AsyncSession}.
638
+ * This config only applies to run results obtained via {@link Session} and {@link AsyncSession}.
597
639
* As with the reactive sessions the batch size is managed by the subscription requests instead.
598
640
*
599
641
* @param size the default record fetch size when pulling records in batches using Bolt V4.
@@ -629,11 +671,11 @@ public ConfigBuilder withConnectionTimeout(long value, TimeUnit unit) {
629
671
var connectionTimeoutMillis = unit .toMillis (value );
630
672
if (connectionTimeoutMillis < 0 ) {
631
673
throw new IllegalArgumentException (
632
- String . format ("The connection timeout may not be smaller than 0, but was %d %s." , value , unit ));
674
+ format ("The connection timeout may not be smaller than 0, but was %d %s." , value , unit ));
633
675
}
634
676
var connectionTimeoutMillisInt = (int ) connectionTimeoutMillis ;
635
677
if (connectionTimeoutMillisInt != connectionTimeoutMillis ) {
636
- throw new IllegalArgumentException (String . format (
678
+ throw new IllegalArgumentException (format (
637
679
"The connection timeout must represent int value when converted to milliseconds %d." ,
638
680
connectionTimeoutMillis ));
639
681
}
@@ -657,7 +699,7 @@ public ConfigBuilder withMaxTransactionRetryTime(long value, TimeUnit unit) {
657
699
var maxRetryTimeMs = unit .toMillis (value );
658
700
if (maxRetryTimeMs < 0 ) {
659
701
throw new IllegalArgumentException (
660
- String . format ("The max retry time may not be smaller than 0, but was %d %s." , value , unit ));
702
+ format ("The max retry time may not be smaller than 0, but was %d %s." , value , unit ));
661
703
}
662
704
this .maxTransactionRetryTimeMillis = maxRetryTimeMs ;
663
705
return this ;
@@ -734,7 +776,7 @@ public ConfigBuilder withMetricsAdapter(MetricsAdapter metricsAdapter) {
734
776
public ConfigBuilder withEventLoopThreads (int size ) {
735
777
if (size < 1 ) {
736
778
throw new IllegalArgumentException (
737
- String . format ("The event loop thread may not be smaller than 1, but was %d." , size ));
779
+ format ("The event loop thread may not be smaller than 1, but was %d." , size ));
738
780
}
739
781
this .eventLoopThreads = size ;
740
782
return this ;
@@ -770,6 +812,42 @@ public ConfigBuilder withNotificationConfig(NotificationConfig notificationConfi
770
812
return this ;
771
813
}
772
814
815
+ /**
816
+ * Sets a minimum severity for notifications produced by the server.
817
+ *
818
+ * @param minimumNotificationSeverity the minimum notification severity
819
+ * @return this builder
820
+ * @since 5.22.0
821
+ */
822
+ @ Preview (name = "GQL-status object" )
823
+ public ConfigBuilder withMinimumNotificationSeverity (NotificationSeverity minimumNotificationSeverity ) {
824
+ if (minimumNotificationSeverity == null ) {
825
+ notificationConfig = NotificationConfig .disableAllConfig ();
826
+ } else {
827
+ notificationConfig = notificationConfig .enableMinimumSeverity (minimumNotificationSeverity );
828
+ }
829
+ return this ;
830
+ }
831
+
832
+ /**
833
+ * Sets a set of disabled classifications for notifications produced by the server.
834
+ *
835
+ * @param disabledNotificationClassifications the set of disabled notification classifications
836
+ * @return this builder
837
+ * @since 5.22.0
838
+ */
839
+ @ Preview (name = "GQL-status object" )
840
+ public ConfigBuilder withDisabledNotificationClassifications (
841
+ Set <NotificationClassification > disabledNotificationClassifications ) {
842
+ var disabledCategories = disabledNotificationClassifications == null
843
+ ? Collections .<NotificationCategory >emptySet ()
844
+ : disabledNotificationClassifications .stream ()
845
+ .map (NotificationCategory .class ::cast )
846
+ .collect (Collectors .toSet ());
847
+ notificationConfig = notificationConfig .disableCategories (disabledCategories );
848
+ return this ;
849
+ }
850
+
773
851
/**
774
852
* Sets if telemetry is disabled on the driver side.
775
853
* <p>
0 commit comments