Skip to content

Commit d55c079

Browse files
authored
RUST-803 Conditionally use hello for monitoring (#600)
1 parent c7947cd commit d55c079

File tree

419 files changed

+8416
-1102
lines changed

Some content is hidden

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

419 files changed

+8416
-1102
lines changed

benchmarks/src/bench/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ pub async fn drop_database(uri: &str, database: &str) -> Result<()> {
138138

139139
let hello = client
140140
.database("admin")
141-
.run_command(doc! { "ismaster": true }, None)
141+
.run_command(doc! { "hello": true }, None)
142142
.await?;
143143

144144
client.database(&database).drop(None).await?;

benchmarks/src/bench/run_command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl Benchmark for RunCommandBenchmark {
3131
Ok(RunCommandBenchmark {
3232
db,
3333
num_iter: options.num_iter,
34-
cmd: doc! { "ismaster": true },
34+
cmd: doc! { "hello": true },
3535
uri: options.uri,
3636
})
3737
}

benchmarks/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ async fn run_benchmarks(
219219
let run_command =
220220
bench::run_benchmark::<RunCommandBenchmark>(run_command_options).await?;
221221

222-
comp_score += score_test(run_command, RUN_COMMAND_BENCH, 0.16, more_info);
222+
comp_score += score_test(run_command, RUN_COMMAND_BENCH, 0.13, more_info);
223223
}
224224

225225
// Small doc insertOne

src/client/auth/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ impl Credential {
383383
}
384384

385385
/// If the mechanism is missing, append the appropriate mechanism negotiation key-value-pair to
386-
/// the provided isMaster command document.
386+
/// the provided hello or legacy hello command document.
387387
pub(crate) fn append_needed_mechanism_negotiation(&self, command: &mut Document) {
388388
if let (Some(username), None) = (self.username.as_ref(), self.mechanism.as_ref()) {
389389
command.insert(

src/client/executor.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use crate::{
3131
UNKNOWN_TRANSACTION_COMMIT_RESULT,
3232
},
3333
event::command::{CommandFailedEvent, CommandStartedEvent, CommandSucceededEvent},
34+
hello::LEGACY_HELLO_COMMAND_NAME_LOWERCASE,
3435
operation::{
3536
AbortTransaction,
3637
AggregateTarget,
@@ -70,7 +71,7 @@ lazy_static! {
7071
pub(crate) static ref HELLO_COMMAND_NAMES: HashSet<&'static str> = {
7172
let mut hash_set = HashSet::new();
7273
hash_set.insert("hello");
73-
hash_set.insert("ismaster");
74+
hash_set.insert(LEGACY_HELLO_COMMAND_NAME_LOWERCASE);
7475
hash_set
7576
};
7677
}

src/client/options/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,7 @@ pub struct ClientOptions {
410410
#[builder(default)]
411411
pub driver_info: Option<DriverInfo>,
412412

413-
/// The amount of time each monitoring thread should wait between sending an isMaster command
414-
/// to its respective server.
413+
/// The amount of time each monitoring thread should wait between performing server checks.
415414
///
416415
/// The default value is 10 seconds.
417416
#[builder(default)]

src/cmap/conn/command.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
bson::Document,
99
client::{options::ServerApi, ClusterTime, HELLO_COMMAND_NAMES, REDACTED_COMMANDS},
1010
error::{Error, ErrorKind, Result},
11-
is_master::{IsMasterCommandResponse, IsMasterReply},
11+
hello::{HelloCommandResponse, HelloReply},
1212
operation::{CommandErrorBody, CommandResponse},
1313
options::{ReadConcern, ReadConcernInternal, ReadConcernLevel, ServerAddress},
1414
selection_criteria::ReadPreference,
@@ -244,12 +244,12 @@ impl RawCommandResponse {
244244
.map_err(|_| Error::invalid_authentication_response(mechanism_name))
245245
}
246246

247-
pub(crate) fn to_is_master_response(&self, round_trip_time: Duration) -> Result<IsMasterReply> {
248-
match self.body::<CommandResponse<IsMasterCommandResponse>>() {
247+
pub(crate) fn to_hello_reply(&self, round_trip_time: Duration) -> Result<HelloReply> {
248+
match self.body::<CommandResponse<HelloCommandResponse>>() {
249249
Ok(response) if response.is_success() => {
250250
let server_address = self.source_address().clone();
251251
let cluster_time = response.cluster_time().cloned();
252-
Ok(IsMasterReply {
252+
Ok(HelloReply {
253253
server_address,
254254
command_response: response.body,
255255
round_trip_time,

src/cmap/conn/stream_description.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::time::Duration;
22

3-
use crate::{client::options::ServerAddress, is_master::IsMasterReply, sdam::ServerType};
3+
use crate::{client::options::ServerAddress, hello::HelloReply, sdam::ServerType};
44

55
/// Contains information about a given server in a format digestible by a connection.
66
#[derive(Debug, Default, Clone)]
@@ -32,24 +32,27 @@ pub(crate) struct StreamDescription {
3232
/// can be included in a write batch. If more than this number of writes are included, the
3333
/// server cannot guarantee space in the response document to reply to the batch.
3434
pub(crate) max_write_batch_size: i64,
35+
36+
/// Whether the server associated with this connection supports the `hello` command.
37+
pub(crate) hello_ok: bool,
3538
}
3639

3740
impl StreamDescription {
38-
/// Constructs a new StreamDescription from an IsMasterReply.
39-
pub(crate) fn from_is_master(reply: IsMasterReply) -> Self {
41+
/// Constructs a new StreamDescription from a `HelloReply`.
42+
pub(crate) fn from_hello_reply(reply: &HelloReply) -> Self {
4043
Self {
41-
server_address: reply.server_address,
44+
server_address: reply.server_address.clone(),
4245
initial_server_type: reply.command_response.server_type(),
4346
max_wire_version: reply.command_response.max_wire_version,
4447
min_wire_version: reply.command_response.min_wire_version,
45-
sasl_supported_mechs: reply.command_response.sasl_supported_mechs,
46-
// TODO RUST-204: Add "saslSupportedMechs" if applicable.
48+
sasl_supported_mechs: reply.command_response.sasl_supported_mechs.clone(),
4749
logical_session_timeout: reply
4850
.command_response
4951
.logical_session_timeout_minutes
5052
.map(|mins| Duration::from_secs(mins as u64 * 60)),
5153
max_bson_object_size: reply.command_response.max_bson_object_size,
5254
max_write_batch_size: reply.command_response.max_write_batch_size,
55+
hello_ok: reply.command_response.hello_ok.unwrap_or(false),
5356
}
5457
}
5558

@@ -78,6 +81,7 @@ impl StreamDescription {
7881
logical_session_timeout: Some(Duration::from_secs(30 * 60)),
7982
max_bson_object_size: 16 * 1024 * 1024,
8083
max_write_batch_size: 100_000,
84+
hello_ok: false,
8185
}
8286
}
8387
}

src/cmap/conn/wire/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
mod header;
22
mod message;
3-
#[cfg(test)]
4-
mod test;
53
mod util;
64

75
pub(crate) use self::{message::Message, util::next_request_id};

src/cmap/conn/wire/test.rs

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)