diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2016-05-09 14:44:42 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2016-05-10 17:35:31 -0400 |
commit | 995ca1226f958da71273266f2150349afc94e71a (patch) | |
tree | 51281224ad3d89fca0630600117a6b62a5b5a328 /src/mongo/s/chunk_version.h | |
parent | 8f8043d6128813e9862b5a5c30a90d007d92c363 (diff) | |
download | mongo-995ca1226f958da71273266f2150349afc94e71a.tar.gz |
SERVER-24071 Introduce ChunkVersion legacy format parser
This change goes towards cleaning up the ChunkVersion class so it has
clearly specified methods for the three variants of parsing, which it
supports.
Also it moves all the catalog types to be under the s/common library so
they can be used not only from the catalog.
Diffstat (limited to 'src/mongo/s/chunk_version.h')
-rw-r--r-- | src/mongo/s/chunk_version.h | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/mongo/s/chunk_version.h b/src/mongo/s/chunk_version.h index 7cfef0533a5..32bafdb7a8b 100644 --- a/src/mongo/s/chunk_version.h +++ b/src/mongo/s/chunk_version.h @@ -77,6 +77,13 @@ public: static StatusWith<ChunkVersion> parseFromBSONForSetShardVersion(const BSONObj& obj); /** + * Interprets the specified BSON content as the format for chunk persistence, which is in the + * form: + * { ..., lastmod: [ <combined major/minor> ], lastmodEpoch: [ <OID epoch> ], ... } + */ + static StatusWith<ChunkVersion> parseFromBSONForChunk(const BSONObj& obj); + + /** * Indicates a dropped collection. All components are zeroes (OID is zero time, zero * machineId/inc). */ @@ -255,12 +262,6 @@ public: // { version : <TS>, versionEpoch : <OID> } object format // - static bool canParseBSON(const BSONObj& obj, const std::string& prefix = "") { - bool canParse; - fromBSON(obj, prefix, &canParse); - return canParse; - } - static ChunkVersion fromBSON(const BSONObj& obj, const std::string& prefix = "") { bool canParse; return fromBSON(obj, prefix, &canParse); @@ -346,10 +347,16 @@ public: void appendForSetShardVersion(BSONObjBuilder* builder) const; /** - * Appends the contents to the specified builder in the format expected by the write commands. + * Appends the contents to the specified builder in the format expected by the sharded commands. */ void appendForCommands(BSONObjBuilder* builder) const; + /** + * Appends the contents to the specified builder in the format expected by the chunk + * serialization/deserialization code. + */ + void appendForChunk(BSONObjBuilder* builder) const; + std::string toString() const { StringBuilder sb; sb << majorVersion() << "|" << minorVersion() << "||" << _epoch; |