diff options
author | Mathias Stearn <mathias@10gen.com> | 2017-06-22 16:55:04 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2017-07-13 16:53:12 -0400 |
commit | a6cc94d141f13feff33178a769c81282c7bc0170 (patch) | |
tree | 1a043a3718c54e8522f8b9bf0932c8d7f96ae79f /src/mongo/db/ftdc/ftdc_server.cpp | |
parent | 8204c7dacf17851057dda165e6d1638cbff70cbf (diff) | |
download | mongo-a6cc94d141f13feff33178a769c81282c7bc0170.tar.gz |
SERVER-29731 Unify logic around directly invoking a command
Diffstat (limited to 'src/mongo/db/ftdc/ftdc_server.cpp')
-rw-r--r-- | src/mongo/db/ftdc/ftdc_server.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/mongo/db/ftdc/ftdc_server.cpp b/src/mongo/db/ftdc/ftdc_server.cpp index 534cbf37650..a4bb5572c7c 100644 --- a/src/mongo/db/ftdc/ftdc_server.cpp +++ b/src/mongo/db/ftdc/ftdc_server.cpp @@ -247,21 +247,14 @@ FTDCSimpleInternalCommandCollector::FTDCSimpleInternalCommandCollector(StringDat StringData name, StringData ns, BSONObj cmdObj) - : _name(name.toString()), _ns(ns.toString()), _cmdObj(std::move(cmdObj)) { - _command = Command::findCommand(command); - invariant(_command); + : _name(name.toString()), _request(OpMsgRequest::fromDBAndBody(ns, std::move(cmdObj))) { + invariant(command == _request.getCommandName()); + invariant(Command::findCommand(command)); // Fail early if it doesn't exist. } void FTDCSimpleInternalCommandCollector::collect(OperationContext* opCtx, BSONObjBuilder& builder) { - std::string errmsg; - - bool ret = _command->run(opCtx, _ns, _cmdObj, errmsg, builder); - - // Some commands return errmsgs when they return false (collstats) - // Some commands return bson objs when they return false (replGetStatus) - // We append the status as needed to ensure readers of the collected data can check the - // status of any individual command. - _command->appendCommandStatus(builder, ret, errmsg); + auto result = Command::runCommandDirectly(opCtx, _request); + builder.appendElements(result); } std::string FTDCSimpleInternalCommandCollector::name() const { |