summaryrefslogtreecommitdiff
path: root/src/mongo/rpc/metadata/sharding_metadata.h
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@mongodb.com>2015-09-16 15:16:44 -0400
committerSpencer T Brody <spencer@mongodb.com>2015-09-17 11:55:12 -0400
commit3619498a9f4ff383cdd546a320abbec11a511bc6 (patch)
tree07c72a7861c0ef171fc562e76acef2a343bbd1c7 /src/mongo/rpc/metadata/sharding_metadata.h
parent0e0a4e5e8a70ce1f6208c613d2897186a0b8a1c3 (diff)
downloadmongo-3619498a9f4ff383cdd546a320abbec11a511bc6.tar.gz
SERVER-19905 SERVER-19855 Put config server optime into its own subobject when sending with commands
Diffstat (limited to 'src/mongo/rpc/metadata/sharding_metadata.h')
-rw-r--r--src/mongo/rpc/metadata/sharding_metadata.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/mongo/rpc/metadata/sharding_metadata.h b/src/mongo/rpc/metadata/sharding_metadata.h
index 048473064b4..b18e415ffb4 100644
--- a/src/mongo/rpc/metadata/sharding_metadata.h
+++ b/src/mongo/rpc/metadata/sharding_metadata.h
@@ -27,6 +27,8 @@
*/
#pragma once
+#include <boost/optional.hpp>
+
#include "mongo/db/jsobj.h"
namespace mongo {
@@ -35,11 +37,17 @@ class BSONObjBuilder;
class Status;
template <typename T>
class StatusWith;
+
+namespace repl {
+class OpTime;
+} // namespace repl
+
namespace rpc {
/**
* This class compromises the reply metadata fields that concern sharding. MongoD attaches
* this information to a command reply, which MongoS uses to process getLastError.
+ * TODO(spencer): Rename this to ShardingResponseMetadata.
*/
class ShardingMetadata {
public:
@@ -87,5 +95,23 @@ private:
OID _lastElectionId;
};
+class ShardingRequestMetadata {
+public:
+ static const char kConfigsvrOpTimeFieldName[];
+
+ /**
+ * Looks in the given command object for a field containing the config server optime, and
+ * returns it if present, or boost::none if not. Returns a non-ok status on parsing error.
+ * Used for extracting the config server optime on mongod that was sent from a mongos.
+ *
+ * TODO(SERVER-20442): Currently this method extracts this information from the main command
+ * description rather than the actual OP_COMMAND metadata section. Ideally this information
+ * should be in the metadata, but we currently have no good way to add metadata to all commands
+ * being *sent* to another server.
+ */
+ static StatusWith<boost::optional<repl::OpTime>> extractConfigServerOpTimeIfPresent(
+ const BSONObj& cmdObj);
+};
+
} // namespace rpc
} // namespace mongo