diff options
author | Pavi Vetriselvan <pavithra.vetriselvan@mongodb.com> | 2020-07-30 12:39:35 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-09-16 01:41:14 +0000 |
commit | 8b8385f99237738faf06de6ee352269569ae3473 (patch) | |
tree | 05abe612671e34b7b2035f28d1318205aa378436 /src/mongo | |
parent | ea8d8df3efa6592f82c2663810586d6222c73731 (diff) | |
download | mongo-8b8385f99237738faf06de6ee352269569ae3473.tar.gz |
SERVER-49986 Convert isMaster command to hello and keep isMaster, ismaster aliases
(cherry picked from commit 9a4be902441496be7ef40e5404a91ac30dc81f77)
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/repl/replication_info.cpp | 13 | ||||
-rw-r--r-- | src/mongo/s/commands/cluster_is_master_cmd.cpp | 12 |
2 files changed, 19 insertions, 6 deletions
diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp index 4007bfda120..afb68ed3314 100644 --- a/src/mongo/db/repl/replication_info.cpp +++ b/src/mongo/db/repl/replication_info.cpp @@ -33,6 +33,7 @@ #include <list> #include <vector> +#include "mongo/base/string_data.h" #include "mongo/client/connpool.h" #include "mongo/db/client.h" #include "mongo/db/commands/server_status.h" @@ -70,6 +71,11 @@ using std::stringstream; namespace repl { namespace { +constexpr auto kHelloString = "hello"_sd; +// Aliases for the hello command in order to provide backwards compatibility. +constexpr auto kCamelCaseIsMasterString = "isMaster"_sd; +constexpr auto kLowerCaseIsMasterString = "ismaster"_sd; + void appendReplicationInfo(OperationContext* opCtx, BSONObjBuilder& result, int level) { ReplicationCoordinator* replCoord = getGlobalReplicationCoordinator(); if (replCoord->getSettings().usingReplSets()) { @@ -214,8 +220,10 @@ public: } } oplogInfoServerStatus; -class CmdIsMaster : public BasicCommand { +class CmdHello final : public BasicCommand { public: + CmdHello() : BasicCommand(kHelloString, {kCamelCaseIsMasterString, kLowerCaseIsMasterString}) {} + bool requiresAuth() const override { return false; } @@ -233,7 +241,6 @@ public: virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, std::vector<Privilege>* out) {} // No auth required - CmdIsMaster() : BasicCommand("isMaster", "ismaster") {} virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, @@ -403,7 +410,7 @@ public: return true; } -} cmdismaster; +} cmdhello; OpCounterServerStatusSection replOpCounterServerStatusSection("opcountersRepl", &replOpCounters); diff --git a/src/mongo/s/commands/cluster_is_master_cmd.cpp b/src/mongo/s/commands/cluster_is_master_cmd.cpp index cf5e9b81bed..d6e2c1b1187 100644 --- a/src/mongo/s/commands/cluster_is_master_cmd.cpp +++ b/src/mongo/s/commands/cluster_is_master_cmd.cpp @@ -30,6 +30,7 @@ #include "mongo/platform/basic.h" +#include "mongo/base/string_data.h" #include "mongo/db/client.h" #include "mongo/db/commands.h" #include "mongo/db/logical_session_cache.h" @@ -48,9 +49,14 @@ namespace mongo { namespace { -class CmdIsMaster : public BasicCommand { +constexpr auto kHelloString = "hello"_sd; +// Aliases for the hello command in order to provide backwards compatibility. +constexpr auto kCamelCaseIsMasterString = "isMaster"_sd; +constexpr auto kLowerCaseIsMasterString = "ismaster"_sd; + +class CmdHello : public BasicCommand { public: - CmdIsMaster() : BasicCommand("isMaster", "ismaster") {} + CmdHello() : BasicCommand(kHelloString, {kCamelCaseIsMasterString, kLowerCaseIsMasterString}) {} bool supportsWriteConcern(const BSONObj& cmd) const override { return false; @@ -141,7 +147,7 @@ public: return true; } -} isMaster; +} hello; } // namespace } // namespace mongo |