diff options
author | Siyuan Zhou <siyuan.zhou@mongodb.com> | 2016-05-17 15:43:35 -0400 |
---|---|---|
committer | Siyuan Zhou <siyuan.zhou@mongodb.com> | 2016-07-05 16:51:04 -0400 |
commit | e3ee305be314d8109ec1f1fd558b7011817dbfe7 (patch) | |
tree | b831be96e3a66c52336d2e4a7ca382e5c8a3206f /src/mongo/db/repl/replset_commands.cpp | |
parent | 71424c1c4b87c5819b1fc5cf114078a6f33c6078 (diff) | |
download | mongo-e3ee305be314d8109ec1f1fd558b7011817dbfe7.tar.gz |
SERVER-24881 Add StepUp Command.
Diffstat (limited to 'src/mongo/db/repl/replset_commands.cpp')
-rw-r--r-- | src/mongo/db/repl/replset_commands.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/mongo/db/repl/replset_commands.cpp b/src/mongo/db/repl/replset_commands.cpp index 12ace8dc728..9130052de75 100644 --- a/src/mongo/db/repl/replset_commands.cpp +++ b/src/mongo/db/repl/replset_commands.cpp @@ -893,5 +893,38 @@ private: } } cmdReplSetElect; +class CmdReplSetStepUp : public ReplSetCommand { +public: + virtual Status checkAuthForCommand(ClientBasic* client, + const std::string& dbname, + const BSONObj& cmdObj) { + ActionSet actions; + actions.addAction(ActionType::replSetStateChange); + if (!AuthorizationSession::get(client)->isAuthorizedForActionsOnResource( + ResourcePattern::forClusterResource(), actions)) { + return Status(ErrorCodes::Unauthorized, "Unauthorized"); + } + return Status::OK(); + } + + CmdReplSetStepUp() : ReplSetCommand("replSetStepUp") {} + +private: + virtual bool run(OperationContext* txn, + const string&, + BSONObj& cmdObj, + int, + string& errmsg, + BSONObjBuilder& result) { + Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result); + if (!status.isOK()) + return appendCommandStatus(result, status); + + status = getGlobalReplicationCoordinator()->stepUpIfEligible(); + + return appendCommandStatus(result, status); + } +} cmdReplSetStepUp; + } // namespace repl } // namespace mongo |