diff options
author | Ben Caimano <ben.caimano@10gen.com> | 2018-06-08 18:53:14 -0400 |
---|---|---|
committer | Ben Caimano <ben.caimano@10gen.com> | 2018-06-08 18:53:14 -0400 |
commit | d1ef07466b2da86ad1933c1e607ef3f3364ba100 (patch) | |
tree | e6ce7d355f7e608010220cbbea52a09e836ca397 /src/mongo/db | |
parent | 211b5c3006f89e8235dd6d795d0c64defc77030d (diff) | |
download | mongo-d1ef07466b2da86ad1933c1e607ef3f3364ba100.tar.gz |
SERVER-35517 Add failpoint mechanism to the mongo shell
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/commands/fail_point_cmd.cpp | 44 |
1 files changed, 13 insertions, 31 deletions
diff --git a/src/mongo/db/commands/fail_point_cmd.cpp b/src/mongo/db/commands/fail_point_cmd.cpp index 567d5f9db0e..23876f2ad83 100644 --- a/src/mongo/db/commands/fail_point_cmd.cpp +++ b/src/mongo/db/commands/fail_point_cmd.cpp @@ -41,9 +41,6 @@ namespace mongo { -using std::string; -using std::stringstream; - /** * Command for modifying installed fail points. * @@ -65,19 +62,19 @@ using std::stringstream; * data: <Object> // optional arbitrary object to store. * } */ -class FaultInjectCmd : public ErrmsgCommandDeprecated { +class FaultInjectCmd : public BasicCommand { public: - FaultInjectCmd() : ErrmsgCommandDeprecated("configureFailPoint") {} + FaultInjectCmd() : BasicCommand("configureFailPoint") {} AllowedOnSecondary secondaryAllowed(ServiceContext*) const override { return AllowedOnSecondary::kAlways; } - virtual bool supportsWriteConcern(const BSONObj& cmd) const override { + bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } - virtual bool adminOnly() const { + bool adminOnly() const override { return true; } @@ -86,35 +83,20 @@ public: } // No auth needed because it only works when enabled via command line. - virtual void addRequiredPrivileges(const std::string& dbname, - const BSONObj& cmdObj, - std::vector<Privilege>* out) const {} + void addRequiredPrivileges(const std::string& dbname, + const BSONObj& cmdObj, + std::vector<Privilege>* out) const override {} std::string help() const override { return "modifies the settings of a fail point"; } - bool errmsgRun(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { - const string failPointName(cmdObj.firstElement().str()); - FailPointRegistry* registry = getGlobalFailPointRegistry(); - FailPoint* failPoint = registry->getFailPoint(failPointName); - - if (failPoint == nullptr) { - errmsg = failPointName + " not found"; - return false; - } - - FailPoint::Mode mode; - FailPoint::ValType val; - BSONObj data; - std::tie(mode, val, data) = uassertStatusOK(FailPoint::parseBSON(cmdObj)); - - failPoint->setMode(mode, val, data); - warning() << "failpoint: " << failPointName << " set to: " << failPoint->toBSON(); + bool run(OperationContext* opCtx, + const std::string& dbname, + const BSONObj& cmdObj, + BSONObjBuilder& result) override { + const std::string failPointName(cmdObj.firstElement().str()); + setGlobalFailPoint(failPointName, cmdObj); return true; } |