-
Notifications
You must be signed in to change notification settings - Fork 1.5k
ClusterSettings
does not compute ClusterConnectionMode
consistently
#1261
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
Conversation
MongoClientSettings#getStreamFactoryFactory() MongoClientSettings.Builder#streamFactoryFactory(StreamFactoryFactory) AsynchronousSocketChannelStreamFactory AsynchronousSocketChannelStreamFactoryFactory BufferProvider SocketStreamFactory Stream StreamFactory StreamFactoryFactory TlsChannelStreamFactoryFactory NettyStreamFactory NettyStreamFactoryFactory JAVA-5161
* Remove builders * Remove now-unused factory configuration * Simplify usage in MongoClient instantiation JAVA-5161
* ServerAddress#getSocketAddress * ServerAddress#getSocketAddresses * UnixServerAddress#getSocketAddress * UnixServerAddress#getUnixSocketAddress JAVA-4937
Since we ended up adding explain support to FindIterable, no reason to leave it deprecated in the legacy API. JAVA-5154
The dead code is a remnant of when the driver supported the full range of OP_REPLY wire protocol message usage. Since the driver now only runs against MongoDB releases that support OP_MSG, OP_REPLY is only used for the response to the `hello` command in the handshake, and therefore most of the OP_REPLY-handling code is no longer on any execution paths. JAVA-5204
Now that Stream is not part of the API, this method can be removed. It only existed due to the possibility that an application creates its own Stream implementation. JAVA-5180
* getStats * isCapped JAVA-5116
JAVA-5149
from the following internal interfaces: * ClusterAwareReadWriteBinding * AsyncClusterAwareReadWriteBinding The interfaces remain as they have picket up a second method. JAVA-5217
JAVA-5142
Since StreamFactoryFactory is now internal, just made that interface extend AutoCloseable in order to simplify MongoClients code JAVA-5158
* ConnectionPoolOpenedEvent * ConnectionAddedEvent * ConnectionRemovedEvent * ConnectionPoolListener#connectionPoolOpened * ConnectionPoolListener#connectionAdded * ConnectionPoolListener#connectionRemoved JAVA-5151
* ClusterListenerAdapter * ConnectionPoolListenerAdapter * ServerListenerAdapter * ServerMonitorListenerAdapter JAVA-5151
JAVA-5142
JAVA-5142
It's still used by IterableCodecProvider, so it can't be removed entirely. (Though IterableCodecProvider is almost entirely supplanted by CollectionCodecProvider, it was not itself deprecated because it provides a codec for any Iterable, while CollectionCodecProvider only provides one for any Collection, which is not quite the same thing). JAVA-5142
325e513
to
8362d0b
Compare
} else if (directConnection != null) { | ||
mode(directConnection ? ClusterConnectionMode.SINGLE : ClusterConnectionMode.MULTIPLE); | ||
hosts(singletonList(createServerAddress(connectionString.getHosts().get(0)))); | ||
} else { | ||
mode = null; | ||
List<ServerAddress> seedList = connectionString.getHosts().stream() | ||
.map(ServerAddressHelper::createServerAddress) | ||
.collect(Collectors.toList()); | ||
mode(ClusterConnectionMode.MULTIPLE).hosts(seedList); | ||
hosts(seedList); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this change, the following test fails:
when:
settings = ClusterSettings.builder()
.applyConnectionString(new ConnectionString('mongodb://example.com:27018'))
.requiredReplicaSetName("test")
.build()
then:
settings.mode == ClusterConnectionMode.MULTIPLE
driver-core/src/main/com/mongodb/connection/ClusterSettings.java
Outdated
Show resolved
Hide resolved
JAVA-5088
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even in relatively simple code like this, I don't find it easy to tease apart the refactoring from the behavioral change that fixes the bug, and would probably prefer that it be split into two commits. But I think I understand everything and the tests look good, so LGTM regardless.
.build() | ||
|
||
then: | ||
settings.mode == ClusterConnectionMode.MULTIPLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A note for us in the future: when run against the original code, this assertion fails
when: | ||
def settings = ClusterSettings.builder().hosts([new ServerAddress()]).requiredReplicaSetName('yeah').build() | ||
|
||
then: | ||
ClusterType.REPLICA_SET == settings.requiredClusterType | ||
ClusterConnectionMode.MULTIPLE == settings.mode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A note for us in the future: when run against the original code, this assertion fails
if (srvHost != null) { | ||
throw new IllegalArgumentException("An SRV host name was provided but the connection mode is not MULTIPLE"); | ||
} else if (builder.hosts.size() > 1) { | ||
throw new IllegalArgumentException("Can not directly connect to more than one server"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Optional]: I've noticed a slightly different wording in the error description for ConnectionString
validation. Specifically, the wording differs: "Direct connections are not supported when using multiple hosts." Given that this change is targeted for the 5.0 release and involves some refactoring, should we ensure consistency in the error descriptions with those in ConnectionString
?
c076264
to
7b3312a
Compare
This PR addresses test concerns expressed in the original PR #1163. New tests discovered more issues, so more changes were done in
ClusterSettings
.JAVA-5088