summaryrefslogtreecommitdiff
path: root/src/mongo/executor/remote_command_response.cpp
diff options
context:
space:
mode:
authorWaley Chen <waleycz@gmail.com>2016-08-03 15:54:57 -0400
committerWaley Chen <waleycz@gmail.com>2016-08-03 15:54:57 -0400
commit05e1c33649e08ec3736121254da7b29a73934788 (patch)
tree591de8a744ed1e31535038474247102e540c209d /src/mongo/executor/remote_command_response.cpp
parent1aeb9f04c0cdaaa4832ada812797b50456986baf (diff)
downloadmongo-05e1c33649e08ec3736121254da7b29a73934788.tar.gz
SERVER-24067 TaskExecutor RemoteCommandCallbackArgs should include elapsedMS and metadata
Diffstat (limited to 'src/mongo/executor/remote_command_response.cpp')
-rw-r--r--src/mongo/executor/remote_command_response.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/mongo/executor/remote_command_response.cpp b/src/mongo/executor/remote_command_response.cpp
index ab67febd598..e611ea0bc2b 100644
--- a/src/mongo/executor/remote_command_response.cpp
+++ b/src/mongo/executor/remote_command_response.cpp
@@ -36,6 +36,49 @@
namespace mongo {
namespace executor {
+RemoteCommandResponse::RemoteCommandResponse(ErrorCodes::Error code, std::string reason)
+ : status(code, reason){};
+
+RemoteCommandResponse::RemoteCommandResponse(ErrorCodes::Error code,
+ std::string reason,
+ Milliseconds millis)
+ : elapsedMillis(millis), status(code, reason) {}
+
+RemoteCommandResponse::RemoteCommandResponse(Status s) : status(std::move(s)) {
+ invariant(!isOK());
+};
+
+RemoteCommandResponse::RemoteCommandResponse(Status s, Milliseconds millis)
+ : elapsedMillis(millis), status(std::move(s)) {
+ invariant(!isOK());
+};
+
+RemoteCommandResponse::RemoteCommandResponse(BSONObj dataObj,
+ BSONObj metadataObj,
+ Milliseconds millis)
+ : data(std::move(dataObj)), metadata(std::move(metadataObj)), 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,
@@ -43,6 +86,10 @@ RemoteCommandResponse::RemoteCommandResponse(const rpc::ReplyInterface& rpcReply
: RemoteCommandResponse(rpcReply.getCommandReply(), rpcReply.getMetadata(), std::move(millis)) {
}
+bool RemoteCommandResponse::isOK() const {
+ return status.isOK();
+}
+
std::string RemoteCommandResponse::toString() const {
return str::stream() << "RemoteResponse -- "
<< " cmd:" << data.toString();