Skip to content

Commit 3137198

Browse files
committed
Add support for GQL Status Object
1 parent f229788 commit 3137198

File tree

80 files changed

+1479
-464
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1479
-464
lines changed

driver/clirr-ignored-differences.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,4 +603,34 @@
603603
<method>org.neo4j.driver.ExecutableQuery withAuthToken(org.neo4j.driver.AuthToken)</method>
604604
</difference>
605605

606+
<difference>
607+
<className>org/neo4j/driver/summary/ResultSummary</className>
608+
<differenceType>7012</differenceType>
609+
<method>org.neo4j.driver.summary.GqlStatusObject gqlStatusObject()</method>
610+
</difference>
611+
612+
<difference>
613+
<className>org/neo4j/driver/summary/ResultSummary</className>
614+
<differenceType>7012</differenceType>
615+
<method>java.util.Set gqlStatusObjects()</method>
616+
</difference>
617+
618+
<difference>
619+
<className>org/neo4j/driver/summary/Notification</className>
620+
<differenceType>7012</differenceType>
621+
<method>java.util.Optional inputPosition()</method>
622+
</difference>
623+
624+
<difference>
625+
<className>org/neo4j/driver/summary/Notification</className>
626+
<differenceType>7012</differenceType>
627+
<method>java.util.Optional classification()</method>
628+
</difference>
629+
630+
<difference>
631+
<className>org/neo4j/driver/summary/Notification</className>
632+
<differenceType>7012</differenceType>
633+
<method>java.util.Optional rawClassification()</method>
634+
</difference>
635+
606636
</differences>

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

Lines changed: 79 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import static org.neo4j.driver.internal.logging.DevNullLogging.DEV_NULL_LOGGING;
2121
import static org.neo4j.driver.internal.util.DriverInfoUtil.driverVersion;
2222

23+
import io.netty.channel.EventLoop;
2324
import java.io.File;
2425
import java.io.Serial;
2526
import java.io.Serializable;
@@ -28,9 +29,14 @@
2829
import java.util.Collections;
2930
import java.util.List;
3031
import java.util.Objects;
32+
import java.util.Optional;
33+
import java.util.Set;
3134
import java.util.concurrent.TimeUnit;
3235
import java.util.logging.Level;
36+
import java.util.stream.Collectors;
37+
import org.neo4j.driver.async.AsyncSession;
3338
import org.neo4j.driver.exceptions.UnsupportedFeatureException;
39+
import org.neo4j.driver.internal.InternalNotificationConfig;
3440
import org.neo4j.driver.internal.SecuritySettings;
3541
import org.neo4j.driver.internal.async.pool.PoolSettings;
3642
import org.neo4j.driver.internal.cluster.RoutingSettings;
@@ -39,6 +45,7 @@
3945
import org.neo4j.driver.net.ServerAddressResolver;
4046
import org.neo4j.driver.util.Experimental;
4147
import org.neo4j.driver.util.Immutable;
48+
import org.neo4j.driver.util.Resource;
4249

4350
/**
4451
* A configuration class to config driver properties.
@@ -223,6 +230,7 @@ public int connectionTimeoutMillis() {
223230

224231
/**
225232
* Returns the maximum connection pool size.
233+
*
226234
* @return the maximum size
227235
*/
228236
public int maxConnectionPoolSize() {
@@ -231,6 +239,7 @@ public int maxConnectionPoolSize() {
231239

232240
/**
233241
* Returns the connection acquisition timeout in milliseconds.
242+
*
234243
* @return the acquisition timeout
235244
*/
236245
public long connectionAcquisitionTimeoutMillis() {
@@ -296,6 +305,7 @@ public long maxTransactionRetryTimeMillis() {
296305

297306
/**
298307
* Returns the fetch size.
308+
*
299309
* @return the fetch size
300310
*/
301311
public long fetchSize() {
@@ -304,6 +314,7 @@ public long fetchSize() {
304314

305315
/**
306316
* Returns notification config.
317+
*
307318
* @return the notification config
308319
* @since 5.7
309320
*/
@@ -312,7 +323,30 @@ public NotificationConfig notificationConfig() {
312323
}
313324

314325
/**
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+
*
316350
* @return the number of threads
317351
*/
318352
public int eventLoopThreads() {
@@ -328,6 +362,7 @@ public boolean isMetricsEnabled() {
328362

329363
/**
330364
* Returns the {@link MetricsAdapter}.
365+
*
331366
* @return the metrics adapter
332367
*/
333368
public MetricsAdapter metricsAdapter() {
@@ -399,7 +434,7 @@ public ConfigBuilder withLogging(Logging logging) {
399434
* Enable logging of leaked sessions.
400435
* <p>
401436
* 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.
403438
* Unclosed sessions will result in socket leaks and could cause {@link OutOfMemoryError}s.
404439
* <p>
405440
* 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) {
579614
public ConfigBuilder withRoutingTablePurgeDelay(long delay, TimeUnit unit) {
580615
var routingTablePurgeDelayMillis = unit.toMillis(delay);
581616
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));
584619
}
585620
this.routingTablePurgeDelayMillis = routingTablePurgeDelayMillis;
586621
return this;
@@ -591,11 +626,11 @@ public ConfigBuilder withRoutingTablePurgeDelay(long delay, TimeUnit unit) {
591626
* This config is only valid when the driver is used with servers that support Bolt V4 (Server version 4.0 and later).
592627
* <p>
593628
* 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}.
595630
* By default, the value is set to {@code 1000}.
596631
* Use {@code -1} to disables back pressure and config client to pull all records at once after each run.
597632
* <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}.
599634
* As with the reactive sessions the batch size is managed by the subscription requests instead.
600635
*
601636
* @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) {
627662
var connectionTimeoutMillis = unit.toMillis(value);
628663
if (connectionTimeoutMillis < 0) {
629664
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));
631666
}
632667
var connectionTimeoutMillisInt = (int) connectionTimeoutMillis;
633668
if (connectionTimeoutMillisInt != connectionTimeoutMillis) {
634-
throw new IllegalArgumentException(String.format(
669+
throw new IllegalArgumentException(format(
635670
"The connection timeout must represent int value when converted to milliseconds %d.",
636671
connectionTimeoutMillis));
637672
}
@@ -655,7 +690,7 @@ public ConfigBuilder withMaxTransactionRetryTime(long value, TimeUnit unit) {
655690
var maxRetryTimeMs = unit.toMillis(value);
656691
if (maxRetryTimeMs < 0) {
657692
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));
659694
}
660695
this.maxTransactionRetryTimeMillis = maxRetryTimeMs;
661696
return this;
@@ -732,7 +767,7 @@ public ConfigBuilder withMetricsAdapter(MetricsAdapter metricsAdapter) {
732767
public ConfigBuilder withEventLoopThreads(int size) {
733768
if (size < 1) {
734769
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));
736771
}
737772
this.eventLoopThreads = size;
738773
return this;
@@ -768,6 +803,40 @@ public ConfigBuilder withNotificationConfig(NotificationConfig notificationConfi
768803
return this;
769804
}
770805

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+
771840
/**
772841
* Sets if telemetry is disabled on the driver side.
773842
* <p>

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,50 +17,48 @@
1717
package org.neo4j.driver;
1818

1919
import java.io.Serializable;
20-
import org.neo4j.driver.internal.InternalNotificationCategory;
21-
import org.neo4j.driver.internal.InternalNotificationCategory.Type;
2220

2321
/**
2422
* Notification category.
2523
*
2624
* @since 5.7
2725
*/
28-
public sealed interface NotificationCategory extends Serializable permits InternalNotificationCategory {
26+
public sealed interface NotificationCategory extends Serializable permits NotificationClassification {
2927
/**
3028
* A hint category.
3129
* <p>
3230
* For instance, the given hint cannot be satisfied.
3331
*/
34-
NotificationCategory HINT = new InternalNotificationCategory(Type.HINT);
32+
NotificationCategory HINT = NotificationClassification.HINT;
3533

3634
/**
3735
* An unrecognized category.
3836
* <p>
3937
* For instance, the query or command mentions entities that are unknown to the system.
4038
*/
41-
NotificationCategory UNRECOGNIZED = new InternalNotificationCategory(Type.UNRECOGNIZED);
39+
NotificationCategory UNRECOGNIZED = NotificationClassification.UNRECOGNIZED;
4240

4341
/**
4442
* An unsupported category.
4543
* <p>
4644
* For instance, the query/command is trying to use features that are not supported by the current system or using
4745
* features that are experimental and should not be used in production.
4846
*/
49-
NotificationCategory UNSUPPORTED = new InternalNotificationCategory(Type.UNSUPPORTED);
47+
NotificationCategory UNSUPPORTED = NotificationClassification.UNSUPPORTED;
5048

5149
/**
5250
* A performance category.
5351
* <p>
5452
* For instance, the query uses costly operations and might be slow.
5553
*/
56-
NotificationCategory PERFORMANCE = new InternalNotificationCategory(Type.PERFORMANCE);
54+
NotificationCategory PERFORMANCE = NotificationClassification.PERFORMANCE;
5755

5856
/**
5957
* A deprecation category.
6058
* <p>
6159
* For instance, the query/command use deprecated features that should be replaced.
6260
*/
63-
NotificationCategory DEPRECATION = new InternalNotificationCategory(Type.DEPRECATION);
61+
NotificationCategory DEPRECATION = NotificationClassification.DEPRECATION;
6462

6563
/**
6664
* A security category.
@@ -72,7 +70,7 @@ public sealed interface NotificationCategory extends Serializable permits Intern
7270
*
7371
* @since 5.14
7472
*/
75-
NotificationCategory SECURITY = new InternalNotificationCategory(Type.SECURITY);
73+
NotificationCategory SECURITY = NotificationClassification.SECURITY;
7674

7775
/**
7876
* A topology category.
@@ -84,12 +82,12 @@ public sealed interface NotificationCategory extends Serializable permits Intern
8482
*
8583
* @since 5.14
8684
*/
87-
NotificationCategory TOPOLOGY = new InternalNotificationCategory(Type.TOPOLOGY);
85+
NotificationCategory TOPOLOGY = NotificationClassification.TOPOLOGY;
8886

8987
/**
9088
* A generic category.
9189
* <p>
9290
* For instance, notifications that are not part of a more specific class.
9391
*/
94-
NotificationCategory GENERIC = new InternalNotificationCategory(Type.GENERIC);
92+
NotificationCategory GENERIC = NotificationClassification.GENERIC;
9593
}

0 commit comments

Comments
 (0)