summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r--src/mongo/db/commands/SConscript1
-rw-r--r--src/mongo/db/commands/explain_cmd.cpp2
-rw-r--r--src/mongo/db/commands/generic.cpp12
-rw-r--r--src/mongo/db/commands/mr_test.cpp8
-rw-r--r--src/mongo/db/commands/write_commands/write_commands.cpp2
5 files changed, 17 insertions, 8 deletions
diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript
index 7f16897f022..908214a6e2f 100644
--- a/src/mongo/db/commands/SConscript
+++ b/src/mongo/db/commands/SConscript
@@ -109,6 +109,7 @@ env.Library(
'$BUILD_DIR/mongo/db/mongohasher',
'$BUILD_DIR/mongo/db/server_options_core',
'$BUILD_DIR/mongo/logger/parse_log_component_settings',
+ '$BUILD_DIR/mongo/rpc/protocol',
],
)
diff --git a/src/mongo/db/commands/explain_cmd.cpp b/src/mongo/db/commands/explain_cmd.cpp
index 003047168db..46b0c6eac3f 100644
--- a/src/mongo/db/commands/explain_cmd.cpp
+++ b/src/mongo/db/commands/explain_cmd.cpp
@@ -92,7 +92,7 @@ public:
_innerRequest{std::move(innerRequest)},
_innerInvocation{std::move(innerInvocation)} {}
- void run(OperationContext* opCtx, CommandReplyBuilder* result) override {
+ void run(OperationContext* opCtx, rpc::ReplyBuilderInterface* result) override {
uassert(50746,
"Explain's child command cannot run on this node. "
"Are you explaining a write command on a secondary?",
diff --git a/src/mongo/db/commands/generic.cpp b/src/mongo/db/commands/generic.cpp
index 277b22aba99..a572b94747c 100644
--- a/src/mongo/db/commands/generic.cpp
+++ b/src/mongo/db/commands/generic.cpp
@@ -108,8 +108,16 @@ public:
return NamespaceString(request().request.getDatabase());
}
- void run(OperationContext* opCtx, CommandReplyBuilder* result) override {
- result->append("echo", request().request.body);
+ void run(OperationContext* opCtx, rpc::ReplyBuilderInterface* result) override {
+ auto sequences = request().request.sequences;
+ for (auto& docSeq : sequences) {
+ auto docBuilder = result->getDocSequenceBuilder(docSeq.name);
+ for (auto& bson : docSeq.objs) {
+ docBuilder.append(bson);
+ }
+ }
+
+ result->getBodyBuilder().append("echo", request().request.body);
}
};
diff --git a/src/mongo/db/commands/mr_test.cpp b/src/mongo/db/commands/mr_test.cpp
index f8c81c473a5..6a1f5d67302 100644
--- a/src/mongo/db/commands/mr_test.cpp
+++ b/src/mongo/db/commands/mr_test.cpp
@@ -47,6 +47,7 @@
#include "mongo/db/repl/replication_coordinator_mock.h"
#include "mongo/db/repl/storage_interface_impl.h"
#include "mongo/db/service_context_d_test_fixture.h"
+#include "mongo/rpc/factory.h"
#include "mongo/rpc/get_status_from_command_result.h"
#include "mongo/scripting/dbdirectclient_factory.h"
#include "mongo/scripting/engine.h"
@@ -425,10 +426,9 @@ Status MapReduceCommandTest::_runCommand(StringData mapCode, StringData reduceCo
ASSERT(command) << "Unable to look up mapReduce command";
auto request = OpMsgRequest::fromDBAndBody(inputNss.db(), _makeCmdObj(mapCode, reduceCode));
- BufBuilder bb;
- CommandReplyBuilder crb(BSONObjBuilder{bb});
- command->parse(_opCtx.get(), request)->run(_opCtx.get(), &crb);
- auto status = getStatusFromCommandResult(crb.getBodyBuilder().asTempObj());
+ auto replyBuilder = rpc::makeReplyBuilder(rpc::Protocol::kOpMsg);
+ command->parse(_opCtx.get(), request)->run(_opCtx.get(), replyBuilder.get());
+ auto status = getStatusFromCommandResult(replyBuilder->getBodyBuilder().asTempObj());
if (!status.isOK()) {
return status.withContext(str::stream() << "mapReduce command failed: " << request.body);
}
diff --git a/src/mongo/db/commands/write_commands/write_commands.cpp b/src/mongo/db/commands/write_commands/write_commands.cpp
index edbd9a6d315..46ebb7d0e9c 100644
--- a/src/mongo/db/commands/write_commands/write_commands.cpp
+++ b/src/mongo/db/commands/write_commands/write_commands.cpp
@@ -225,7 +225,7 @@ private:
// Customization point for 'run'.
virtual void runImpl(OperationContext* opCtx, BSONObjBuilder& result) const = 0;
- void run(OperationContext* opCtx, CommandReplyBuilder* result) final {
+ void run(OperationContext* opCtx, rpc::ReplyBuilderInterface* result) final {
try {
try {
_transactionChecks(opCtx);