diff options
Diffstat (limited to 'src/mongo/s/chunk_version.h')
-rw-r--r-- | src/mongo/s/chunk_version.h | 58 |
1 files changed, 11 insertions, 47 deletions
diff --git a/src/mongo/s/chunk_version.h b/src/mongo/s/chunk_version.h index 25034d4c5f4..fc2f637be10 100644 --- a/src/mongo/s/chunk_version.h +++ b/src/mongo/s/chunk_version.h @@ -372,6 +372,17 @@ public: b.appendElements(toBSONWithPrefix(prefix)); } + /** + * Appends the contents to the specified builder in the format expected by the setShardVersion + * command. + */ + void appendForSetShardVersion(BSONObjBuilder* builder) const; + + /** + * Appends the contents to the specified builder in the format expected by the write commands. + */ + void appendForCommands(BSONObjBuilder* builder) const; + BSONObj toBSON() const { // ChunkVersion wants to be an array. BSONArrayBuilder b; @@ -404,51 +415,4 @@ inline std::ostream& operator<<(std::ostream& s, const ChunkVersion& v) { return s; } - -/** - * Represents a chunk version along with the optime from when it was retrieved. Provides logic to - * serialize and deserialize the combo to BSON. - */ -class ChunkVersionAndOpTime { -public: - ChunkVersionAndOpTime(ChunkVersion chunkVersion); - ChunkVersionAndOpTime(ChunkVersion chunkVersion, repl::OpTime ts); - - const ChunkVersion& getVersion() const { - return _verAndOpT.value; - } - - const repl::OpTime& getOpTime() const { - return _verAndOpT.opTime; - } - - /** - * Interprets the contents of the BSON documents as having been constructed in the format for - * write commands. The optime component is optional for backwards compatibility and if not - * present, the optime will be default initialized. - */ - static StatusWith<ChunkVersionAndOpTime> parseFromBSONForCommands(const BSONObj& obj); - - /** - * Interprets the contents of the BSON document as having been constructed in the format for the - * setShardVersion command. The optime component is optional for backwards compatibility and if - * not present, the optime will be default initialized. - */ - static StatusWith<ChunkVersionAndOpTime> parseFromBSONForSetShardVersion(const BSONObj& obj); - - /** - * Appends the contents to the specified builder in the format expected by the setShardVersion - * command. - */ - void appendForSetShardVersion(BSONObjBuilder* builder) const; - - /** - * Appends the contents to the specified builder in the format expected by the write commands. - */ - void appendForCommands(BSONObjBuilder* builder) const; - -private: - OpTimePair<ChunkVersion> _verAndOpT; -}; - } // namespace mongo |