summaryrefslogtreecommitdiff
path: root/src/mongo/executor
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2018-07-25 17:33:21 -0400
committerMathias Stearn <mathias@10gen.com>2018-07-30 14:13:08 -0400
commita5f3bf878d5059215fbc5a5a371aaf2d8a85e8b9 (patch)
tree86baac1bd319bbe02ca31c2404d0b631ff5a25ad /src/mongo/executor
parentcca8ad6cf6f47e86158a8636b6a07743bd115fcc (diff)
downloadmongo-a5f3bf878d5059215fbc5a5a371aaf2d8a85e8b9.tar.gz
SERVER-33135 Remove metadata accessors from command reply APIs
Now that OP_COMMAND is dead, all remaining implementations return the same BSONObj for data and metadata.
Diffstat (limited to 'src/mongo/executor')
-rw-r--r--src/mongo/executor/network_interface_mock.cpp7
-rw-r--r--src/mongo/executor/network_interface_mock_test.cpp8
-rw-r--r--src/mongo/executor/network_interface_tl.cpp2
-rw-r--r--src/mongo/executor/network_test_env.cpp9
-rw-r--r--src/mongo/executor/remote_command_response.cpp18
-rw-r--r--src/mongo/executor/remote_command_response.h8
6 files changed, 17 insertions, 35 deletions
diff --git a/src/mongo/executor/network_interface_mock.cpp b/src/mongo/executor/network_interface_mock.cpp
index 42cda1b4005..942d3795eea 100644
--- a/src/mongo/executor/network_interface_mock.cpp
+++ b/src/mongo/executor/network_interface_mock.cpp
@@ -326,7 +326,7 @@ void NetworkInterfaceMock::scheduleResponse(NetworkOperationIterator noi,
if (_metadataHook && response.isOK()) {
_metadataHook
->readReplyMetadata(
- noi->getRequest().opCtx, noi->getRequest().target.toString(), response.metadata)
+ noi->getRequest().opCtx, noi->getRequest().target.toString(), response.data)
.transitional_ignore();
}
@@ -335,8 +335,7 @@ void NetworkInterfaceMock::scheduleResponse(NetworkOperationIterator noi,
}
RemoteCommandRequest NetworkInterfaceMock::scheduleSuccessfulResponse(const BSONObj& response) {
- BSONObj metadata;
- return scheduleSuccessfulResponse(RemoteCommandResponse(response, metadata, Milliseconds(0)));
+ return scheduleSuccessfulResponse(RemoteCommandResponse(response, Milliseconds(0)));
}
RemoteCommandRequest NetworkInterfaceMock::scheduleSuccessfulResponse(
@@ -479,7 +478,7 @@ void NetworkInterfaceMock::_connectThenEnqueueOperation_inlock(const HostAndPort
auto handshakeReply = (handshakeReplyIter != std::end(_handshakeReplies))
? handshakeReplyIter->second
- : RemoteCommandResponse(BSONObj(), BSONObj(), Milliseconds(0));
+ : RemoteCommandResponse(BSONObj(), Milliseconds(0));
auto valid = _hook->validateHost(target, op.getRequest().cmdObj, handshakeReply);
if (!valid.isOK()) {
diff --git a/src/mongo/executor/network_interface_mock_test.cpp b/src/mongo/executor/network_interface_mock_test.cpp
index a09ed4aeac0..ef7aebbdb9a 100644
--- a/src/mongo/executor/network_interface_mock_test.cpp
+++ b/src/mongo/executor/network_interface_mock_test.cpp
@@ -116,8 +116,8 @@ TEST_F(NetworkInterfaceMockTest, ConnectionHook) {
RemoteCommandResponse expectedResponse{BSON("foo"
<< "bar"
<< "baz"
- << "garply"),
- BSON("bar"
+ << "garply"
+ << "bar"
<< "baz"),
Milliseconds(30)};
@@ -125,8 +125,7 @@ TEST_F(NetworkInterfaceMockTest, ConnectionHook) {
auto isMasterReplyData = BSON("iamyour"
<< "father");
- RemoteCommandResponse isMasterReply{
- isMasterReplyData.copy(), BSON("blah" << 2), Milliseconds(20)};
+ RemoteCommandResponse isMasterReply{isMasterReplyData.copy(), Milliseconds(20)};
net().setHandshakeReplyForHost(testHost(), std::move(isMasterReply));
@@ -166,7 +165,6 @@ TEST_F(NetworkInterfaceMockTest, ConnectionHook) {
testHost(), "testDB", BSON("test" << 1), rpc::makeEmptyMetadata(), nullptr};
RemoteCommandResponse actualResponseExpected{BSON("1212121212"
<< "12121212121212"),
- BSONObj(),
Milliseconds(0)};
ASSERT_OK(net().startCommand(cb, actualCommandExpected, [&](RemoteCommandResponse resp) {
diff --git a/src/mongo/executor/network_interface_tl.cpp b/src/mongo/executor/network_interface_tl.cpp
index 923d25f565e..3c885feab5f 100644
--- a/src/mongo/executor/network_interface_tl.cpp
+++ b/src/mongo/executor/network_interface_tl.cpp
@@ -360,7 +360,7 @@ Future<RemoteCommandResponse> NetworkInterfaceTL::_onAcquireConn(
if (_metadataHook && response.status.isOK()) {
auto target = state->conn->getHostAndPort().toString();
response.status =
- _metadataHook->readReplyMetadata(nullptr, std::move(target), response.metadata);
+ _metadataHook->readReplyMetadata(nullptr, std::move(target), response.data);
}
return RemoteCommandResponse(std::move(response));
diff --git a/src/mongo/executor/network_test_env.cpp b/src/mongo/executor/network_test_env.cpp
index bc782c8ce8c..d60bd0d4fa7 100644
--- a/src/mongo/executor/network_test_env.cpp
+++ b/src/mongo/executor/network_test_env.cpp
@@ -52,7 +52,7 @@ void NetworkTestEnv::onCommand(OnCommandFunction func) {
if (resultStatus.isOK()) {
BSONObjBuilder result(std::move(resultStatus.getValue()));
CommandHelpers::appendCommandStatusNoThrow(result, resultStatus.getStatus());
- const RemoteCommandResponse response(result.obj(), BSONObj(), Milliseconds(1));
+ const RemoteCommandResponse response(result.obj(), Milliseconds(1));
_mockNetwork->scheduleResponse(noi, _mockNetwork->now(), response);
} else {
@@ -75,8 +75,7 @@ void NetworkTestEnv::onCommandWithMetadata(OnCommandWithMetadataFunction func) {
if (cmdResponseStatus.isOK()) {
BSONObjBuilder result(std::move(cmdResponseStatus.data));
CommandHelpers::appendCommandStatusNoThrow(result, cmdResponseStatus.status);
- const RemoteCommandResponse response(
- result.obj(), cmdResponseStatus.metadata, Milliseconds(1));
+ const RemoteCommandResponse response(result.obj(), Milliseconds(1));
_mockNetwork->scheduleResponse(noi, _mockNetwork->now(), response);
} else {
@@ -128,10 +127,10 @@ void NetworkTestEnv::onFindWithMetadataCommand(OnFindCommandWithMetadataFunction
const NamespaceString nss =
NamespaceString(request.dbname, request.cmdObj.firstElement().String());
- BSONObjBuilder resultBuilder;
+ BSONObjBuilder resultBuilder(std::move(metadata));
appendCursorResponseObject(0LL, nss.toString(), arr.arr(), &resultBuilder);
- return RemoteCommandResponse(resultBuilder.obj(), metadata, Milliseconds(1));
+ return RemoteCommandResponse(resultBuilder.obj(), Milliseconds(1));
});
}
diff --git a/src/mongo/executor/remote_command_response.cpp b/src/mongo/executor/remote_command_response.cpp
index 4fb8af3ccf2..e40917843cb 100644
--- a/src/mongo/executor/remote_command_response.cpp
+++ b/src/mongo/executor/remote_command_response.cpp
@@ -54,38 +54,29 @@ RemoteCommandResponse::RemoteCommandResponse(Status s, Milliseconds millis)
invariant(!isOK());
};
-RemoteCommandResponse::RemoteCommandResponse(BSONObj dataObj,
- BSONObj metadataObj,
- Milliseconds millis)
- : data(std::move(dataObj)), metadata(std::move(metadataObj)), elapsedMillis(millis) {
+RemoteCommandResponse::RemoteCommandResponse(BSONObj dataObj, Milliseconds millis)
+ : data(std::move(dataObj)), elapsedMillis(millis) {
// The buffer backing the default empty BSONObj has static duration so it is effectively
// owned.
invariant(data.isOwned() || data.objdata() == BSONObj().objdata());
- invariant(metadata.isOwned() || metadata.objdata() == BSONObj().objdata());
};
RemoteCommandResponse::RemoteCommandResponse(Message messageArg,
BSONObj dataObj,
- BSONObj metadataObj,
Milliseconds millis)
: message(std::make_shared<const Message>(std::move(messageArg))),
data(std::move(dataObj)),
- metadata(std::move(metadataObj)),
elapsedMillis(millis) {
if (!data.isOwned()) {
data.shareOwnershipWith(message->sharedBuffer());
}
- if (!metadata.isOwned()) {
- metadata.shareOwnershipWith(message->sharedBuffer());
- }
}
// TODO(amidvidy): we currently discard output docs when we use this constructor. We should
// have RCR hold those too, but we need more machinery before that is possible.
RemoteCommandResponse::RemoteCommandResponse(const rpc::ReplyInterface& rpcReply,
Milliseconds millis)
- : RemoteCommandResponse(rpcReply.getCommandReply(), rpcReply.getMetadata(), std::move(millis)) {
-}
+ : RemoteCommandResponse(rpcReply.getCommandReply(), std::move(millis)) {}
bool RemoteCommandResponse::isOK() const {
return status.isOK();
@@ -101,8 +92,7 @@ bool RemoteCommandResponse::operator==(const RemoteCommandResponse& rhs) const {
return true;
}
SimpleBSONObjComparator bsonComparator;
- return bsonComparator.evaluate(data == rhs.data) &&
- bsonComparator.evaluate(metadata == rhs.metadata) && elapsedMillis == rhs.elapsedMillis;
+ return bsonComparator.evaluate(data == rhs.data) && elapsedMillis == rhs.elapsedMillis;
}
bool RemoteCommandResponse::operator!=(const RemoteCommandResponse& rhs) const {
diff --git a/src/mongo/executor/remote_command_response.h b/src/mongo/executor/remote_command_response.h
index 0dd51f68ba8..894ca915e7d 100644
--- a/src/mongo/executor/remote_command_response.h
+++ b/src/mongo/executor/remote_command_response.h
@@ -61,12 +61,9 @@ struct RemoteCommandResponse {
RemoteCommandResponse(Status s, Milliseconds millis);
- RemoteCommandResponse(BSONObj dataObj, BSONObj metadataObj, Milliseconds millis);
+ RemoteCommandResponse(BSONObj dataObj, Milliseconds millis);
- RemoteCommandResponse(Message messageArg,
- BSONObj dataObj,
- BSONObj metadataObj,
- Milliseconds millis);
+ RemoteCommandResponse(Message messageArg, BSONObj dataObj, Milliseconds millis);
RemoteCommandResponse(const rpc::ReplyInterface& rpcReply, Milliseconds millis);
@@ -79,7 +76,6 @@ struct RemoteCommandResponse {
std::shared_ptr<const Message> message; // May be null.
BSONObj data; // Always owned. May point into message.
- BSONObj metadata; // Always owned. May point into message.
boost::optional<Milliseconds> elapsedMillis;
Status status = Status::OK();
};