summaryrefslogtreecommitdiff
path: root/src/mongo/client/dbclient.cpp
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2017-10-14 21:54:01 -0400
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2017-10-14 21:54:01 -0400
commit2c5511c8c411c70ac1063d1209764e71f83d0b1a (patch)
tree17eefbaa6e2a7a0416ae036f26e7822d9cf8d982 /src/mongo/client/dbclient.cpp
parent7efbb340cd781d097c153c48c64fb442bbe2a22b (diff)
downloadmongo-2c5511c8c411c70ac1063d1209764e71f83d0b1a.tar.gz
SERVER-31456 Expose server type on Mongo connection object.
This makes it possible to prevent the mongo shell from gossiping a clusterTime to stand-alone mongod processes when the mongo shell is also connected to a replica set or a sharded cluster.
Diffstat (limited to 'src/mongo/client/dbclient.cpp')
-rw-r--r--src/mongo/client/dbclient.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/client/dbclient.cpp b/src/mongo/client/dbclient.cpp
index d85032af84b..2ce3628e7de 100644
--- a/src/mongo/client/dbclient.cpp
+++ b/src/mongo/client/dbclient.cpp
@@ -861,6 +861,18 @@ Status DBClientConnection::connect(const HostAndPort& serverAddress, StringData
}
{
+ // The Server Discovery and Monitoring (SDAM) specification identifies a replica set member
+ // as either (a) having a "setName" field in the isMaster response, or (b) having
+ // "isreplicaset: true" in the isMaster response.
+ //
+ // https://github.com/mongodb/specifications/blob/c386e23724318e2fa82f4f7663d77581b755b2c3/
+ // source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#type
+ const bool hasSetNameField = swIsMasterReply.data.hasField("setName");
+ const bool isReplicaSetField = swIsMasterReply.data.getBoolField("isreplicaset");
+ _isReplicaSetMember = hasSetNameField || isReplicaSetField;
+ }
+
+ {
std::string msgField;
auto msgFieldExtractStatus = bsonExtractStringField(swIsMasterReply.data, "msg", &msgField);