diff options
author | Daniel Gottlieb <daniel.gottlieb@mongodb.com> | 2020-09-30 23:37:25 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-10-01 05:24:34 +0000 |
commit | d286a563d4ad921331d7d3846181a5bb7192a31d (patch) | |
tree | 35229ff3b0dd0a89c6986e0221a805bdb7e5903c /src/mongo/rpc | |
parent | e66093f0a8ee3cd95dea9480028a6da814bb1854 (diff) | |
download | mongo-d286a563d4ad921331d7d3846181a5bb7192a31d.tar.gz |
SERVER-49893: Do oplog fetching.
Diffstat (limited to 'src/mongo/rpc')
-rw-r--r-- | src/mongo/rpc/message.cpp | 28 | ||||
-rw-r--r-- | src/mongo/rpc/message.h | 2 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/mongo/rpc/message.cpp b/src/mongo/rpc/message.cpp index e002b35ec37..ac4a3dac03b 100644 --- a/src/mongo/rpc/message.cpp +++ b/src/mongo/rpc/message.cpp @@ -31,7 +31,10 @@ #include "mongo/rpc/message.h" +#include <fmt/format.h> + #include "mongo/platform/atomic_word.h" +#include "mongo/rpc/op_msg.h" namespace mongo { @@ -43,4 +46,29 @@ int32_t nextMessageId() { return NextMsgId.fetchAndAdd(1); } +std::string Message::opMsgDebugString() const { + MsgData::ConstView headerView = header(); + auto opMsgRequest = OpMsgRequest::parse(*this); + std::stringstream docSequences; + int idx = 0; + for (const auto& seq : opMsgRequest.sequences) { + docSequences << fmt::format("Sequence Idx: {} Sequence Name: {}", idx++, seq.name) + << std::endl; + for (const auto& obj : seq.objs) { + docSequences << fmt::format("\t{}", obj.toString()) << std::endl; + } + } + + return fmt::format( + "Length: {} RequestId: {} ResponseTo: {} OpCode: {} Flags: {} Body: {}\n" + "Sections: {}", + headerView.getLen(), + headerView.getId(), + headerView.getResponseToMsgId(), + headerView.getNetworkOp(), + OpMsg::flags(*this), + opMsgRequest.body.toString(), + docSequences.str()); +} + } // namespace mongo diff --git a/src/mongo/rpc/message.h b/src/mongo/rpc/message.h index 2acb34a632a..38ecf8b12e7 100644 --- a/src/mongo/rpc/message.h +++ b/src/mongo/rpc/message.h @@ -471,6 +471,8 @@ public: return _buf; } + std::string opMsgDebugString() const; + private: SharedBuffer _buf; }; |