Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade mongodb-client to 5.1.3 #42445

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
<liquibase-mongodb.version>4.29.0</liquibase-mongodb.version>
<snakeyaml.version>2.2</snakeyaml.version>
<osgi.version>6.0.0</osgi.version>
<mongo-client.version>4.11.1</mongo-client.version>
<mongo-client.version>5.1.3</mongo-client.version>
<mongo-crypt.version>1.11.0</mongo-crypt.version>
<proton-j.version>0.34.1</proton-j.version>
<javaparser.version>3.26.1</javaparser.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class FindOptions {
private Bson projection;
private Bson sort;
private boolean noCursorTimeout;
private boolean oplogReplay;
private boolean partial;
private CursorType cursorType;
private Collation collation;
Expand Down Expand Up @@ -137,17 +136,6 @@ public FindOptions noCursorTimeout(boolean noCursorTimeout) {
return this;
}

/**
* Users should not set this under normal circumstances.
*
* @param oplogReplay if oplog replay is enabled
* @return this
*/
public FindOptions oplogReplay(boolean oplogReplay) {
this.oplogReplay = oplogReplay;
return this;
}

/**
* Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).
*
Expand Down Expand Up @@ -294,9 +282,6 @@ public <T> FindPublisher<T> apply(FindPublisher<T> stream) {
if (noCursorTimeout) {
publisher = publisher.noCursorTimeout(true);
}
if (oplogReplay) {
publisher = publisher.oplogReplay(true);
}
Comment on lines -297 to -299
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also drop the field/method in our class?

It doesn't have any replacement that we would need to support?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your attentiveness, yes we should drop the field. I'll take care of it.

According to the 4.11.1 Javadocs this option isn't supported on a database level from MongoDB 4.4 onwards.

No additional options were introduced between the versions.

if (partial) {
publisher = publisher.partial(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public class MapReduceOptions {
private long maxTime;
private MapReduceAction action;
private String databaseName;
private boolean sharded;
private boolean nonAtomic;
Comment on lines -28 to -29
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no replacement or additional fields we need to support?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the 4.11.1 Javadocs these two options aren't supported on a database level from MongoDB 4.4 onwards.

In comparison to 4.11.1 only those two fields were removed and none were added.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there will be more work that needs to be invested in this area in the future.
The whole Map-Reduce functionality was deprecated in version 5.0 and should be replaced with aggregates.
See Map-Reduce.

private boolean bypassDocumentValidation;
private Collation collation;

Expand Down Expand Up @@ -159,30 +157,6 @@ public MapReduceOptions databaseName(String databaseName) {
return this;
}

/**
* Sets if the output database is sharded
*
* @param sharded if the output database is sharded
* @return this
*/
public MapReduceOptions sharded(boolean sharded) {
this.sharded = sharded;
return this;
}

/**
* Sets if the post-processing step will prevent MongoDB from locking the database.
* <p>
* Valid only with the {@code MapReduceAction.MERGE} or {@code MapReduceAction.REDUCE} actions.
*
* @param nonAtomic if the post-processing step will prevent MongoDB from locking the database.
* @return this
*/
public MapReduceOptions nonAtomic(boolean nonAtomic) {
this.nonAtomic = nonAtomic;
return this;
}

/**
* Sets the bypass document level validation flag.
*
Expand Down Expand Up @@ -246,8 +220,6 @@ public <T> MapReducePublisher<T> apply(MapReducePublisher<T> stream) {
if (databaseName != null) {
publisher = publisher.databaseName(databaseName);
}
publisher = publisher.sharded(sharded);
publisher = publisher.nonAtomic(nonAtomic);
publisher = publisher.bypassDocumentValidation(bypassDocumentValidation);
if (collation != null) {
publisher = publisher.collation(collation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
import org.eclipse.microprofile.metrics.Tag;

import com.mongodb.connection.ServerId;
import com.mongodb.event.ConnectionAddedEvent;
import com.mongodb.event.ConnectionCheckedInEvent;
import com.mongodb.event.ConnectionCheckedOutEvent;
import com.mongodb.event.ConnectionPoolClosedEvent;
import com.mongodb.event.ConnectionClosedEvent;
import com.mongodb.event.ConnectionCreatedEvent;
import com.mongodb.event.ConnectionPoolCreatedEvent;
import com.mongodb.event.ConnectionPoolListener;
import com.mongodb.event.ConnectionPoolOpenedEvent;
import com.mongodb.event.ConnectionRemovedEvent;

import io.smallrye.metrics.MetricRegistries;

Expand All @@ -23,17 +22,13 @@ public class MongoMetricsConnectionPoolListener implements ConnectionPoolListene
private final static String CHECKED_OUT_COUNT_NAME = "mongodb.connection-pool.checked-out-count";

@Override
public void connectionPoolOpened(ConnectionPoolOpenedEvent event) {
public void connectionPoolCreated(ConnectionPoolCreatedEvent event) {
Tag[] tags = createTags(event.getServerId());

registerGauge(SIZE_NAME, "the current size of the pool, including idle and and in-use members", tags);
registerGauge(CHECKED_OUT_COUNT_NAME, "the current count of connections that are currently in use", tags);
}

@Override
public void connectionPoolClosed(ConnectionPoolClosedEvent event) {
}

@Override
public void connectionCheckedOut(ConnectionCheckedOutEvent event) {
MetricID metricID = createMetricID(CHECKED_OUT_COUNT_NAME, event.getConnectionId().getServerId());
Expand All @@ -57,7 +52,7 @@ public void connectionCheckedIn(ConnectionCheckedInEvent event) {
}

@Override
public void connectionAdded(ConnectionAddedEvent event) {
public void connectionCreated(ConnectionCreatedEvent event) {

MetricID metricID = createMetricID(SIZE_NAME, event.getConnectionId().getServerId());

Expand All @@ -69,7 +64,7 @@ public void connectionAdded(ConnectionAddedEvent event) {
}

@Override
public void connectionRemoved(ConnectionRemovedEvent event) {
public void connectionClosed(ConnectionClosedEvent event) {

MetricID metricID = createMetricID(SIZE_NAME, event.getConnectionId().getServerId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
import com.mongodb.MongoCompressor;
import com.mongodb.ServerAddress;
import com.mongodb.UnixServerAddress;
import com.mongodb.connection.BufferProvider;
import com.mongodb.connection.SocketSettings;
import com.mongodb.connection.SocketStreamFactory;
import com.mongodb.connection.SslSettings;
import com.mongodb.connection.Stream;
import com.mongodb.internal.connection.BufferProvider;
import com.mongodb.internal.connection.InternalStreamConnection;
import com.mongodb.internal.connection.ServerAddressHelper;
import com.mongodb.internal.connection.SocketStream;
import com.mongodb.internal.connection.SocketStreamFactory;
import com.mongodb.internal.connection.Stream;
import com.mongodb.internal.connection.UnixSocketChannelStream;
import com.mongodb.lang.Nullable;
import com.mongodb.spi.dns.InetAddressResolver;
import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.Delete;
import com.oracle.svm.core.annotate.Substitute;
Expand Down Expand Up @@ -74,25 +75,24 @@ final class UnixServerAddressSubstitution {
@TargetClass(SocketStreamFactory.class)
final class SocketStreamFactorySubstitution {

@Alias
private InetAddressResolver inetAddressResolver;
@Alias
private SocketSettings settings;
@Alias
private SslSettings sslSettings;
@Alias
private SocketFactory socketFactory;
@Alias
private BufferProvider bufferProvider;

@Substitute
public Stream create(final ServerAddress serverAddress) {
Stream stream;
if (socketFactory != null) {
stream = new SocketStream(serverAddress, settings, sslSettings, socketFactory, bufferProvider);
} else if (sslSettings.isEnabled()) {
stream = new SocketStream(serverAddress, settings, sslSettings, getSslContext().getSocketFactory(),
bufferProvider);
if (sslSettings.isEnabled()) {
stream = new SocketStream(serverAddress, inetAddressResolver, settings, sslSettings,
getSslContext().getSocketFactory(), bufferProvider);
} else {
stream = new SocketStream(serverAddress, settings, sslSettings, SocketFactory.getDefault(), bufferProvider);
stream = new SocketStream(serverAddress, inetAddressResolver, settings, sslSettings,
SocketFactory.getDefault(), bufferProvider);
}
return stream;
}
Expand Down
Loading