diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2022-06-16 20:50:42 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-06-16 22:33:36 +0000 |
commit | 11feb08b20e51a5c2be42132f1f3be64b0298b1e (patch) | |
tree | 7d8e1b24fa7131c23f9beb36560ef3bdf72adb9b /src/mongo/s/catalog | |
parent | 2fc1d7177e4b8c79c8e307d37cf901bed4bfadf8 (diff) | |
download | mongo-11feb08b20e51a5c2be42132f1f3be64b0298b1e.tar.gz |
SERVER-65530 Get rid of the old ChunkVersion serialization formats
Diffstat (limited to 'src/mongo/s/catalog')
-rw-r--r-- | src/mongo/s/catalog/type_chunk.cpp | 4 | ||||
-rw-r--r-- | src/mongo/s/catalog/type_chunk.h | 2 | ||||
-rw-r--r-- | src/mongo/s/catalog/type_chunk_test.cpp | 47 |
3 files changed, 15 insertions, 38 deletions
diff --git a/src/mongo/s/catalog/type_chunk.cpp b/src/mongo/s/catalog/type_chunk.cpp index 0b1e431e04c..8ce3d377491 100644 --- a/src/mongo/s/catalog/type_chunk.cpp +++ b/src/mongo/s/catalog/type_chunk.cpp @@ -64,8 +64,6 @@ const BSONField<BSONObj> ChunkType::max("max"); const BSONField<std::string> ChunkType::shard("shard"); const BSONField<bool> ChunkType::jumbo("jumbo"); const BSONField<Date_t> ChunkType::lastmod("lastmod"); -const BSONField<OID> ChunkType::epoch("lastmodEpoch"); -const BSONField<Timestamp> ChunkType::timestamp("lastmodTimestamp"); const BSONField<BSONObj> ChunkType::history("history"); const BSONField<int64_t> ChunkType::estimatedSizeBytes("estimatedDataSizeBytes"); const BSONField<bool> ChunkType::historyIsAt40("historyIsAt40"); @@ -444,7 +442,7 @@ StatusWith<ChunkType> ChunkType::parseFromNetworkRequest(const BSONObj& source) } // Parse version. - chunk._version = ChunkVersion::fromBSONLegacyOrNewerFormat(source, ChunkType::lastmod()); + chunk._version = ChunkVersion::parse(source[ChunkType::lastmod()]); return chunk; } diff --git a/src/mongo/s/catalog/type_chunk.h b/src/mongo/s/catalog/type_chunk.h index c073009ba71..30de46edf3a 100644 --- a/src/mongo/s/catalog/type_chunk.h +++ b/src/mongo/s/catalog/type_chunk.h @@ -207,8 +207,6 @@ public: static const BSONField<std::string> shard; static const BSONField<bool> jumbo; static const BSONField<Date_t> lastmod; - static const BSONField<OID> epoch; - static const BSONField<Timestamp> timestamp; static const BSONField<BSONObj> history; static const BSONField<int64_t> estimatedSizeBytes; static const BSONField<bool> historyIsAt40; diff --git a/src/mongo/s/catalog/type_chunk_test.cpp b/src/mongo/s/catalog/type_chunk_test.cpp index f734ce07bf5..bc8d012f290 100644 --- a/src/mongo/s/catalog/type_chunk_test.cpp +++ b/src/mongo/s/catalog/type_chunk_test.cpp @@ -27,19 +27,15 @@ * it in the license file. */ -#include "mongo/platform/basic.h" - -#include "mongo/s/catalog/type_chunk.h" - #include "mongo/base/status_with.h" #include "mongo/db/jsobj.h" +#include "mongo/s/catalog/type_chunk.h" #include "mongo/unittest/unittest.h" #include "mongo/util/time_support.h" namespace mongo { namespace { -using std::string; using unittest::assertGet; const BSONObj kMin = BSON("a" << 10); @@ -56,24 +52,21 @@ TEST(ChunkType, MissingConfigRequiredFields) { BSONObj objModNS = BSON(ChunkType::name(OID::gen()) << ChunkType::min(BSON("a" << 10 << "b" << 10)) << ChunkType::max(BSON("a" << 20)) - << "lastmod" << Timestamp(chunkVersion.toLong()) << "lastmodEpoch" - << chunkVersion.epoch() << ChunkType::shard("shard0001")); + << "lastmod" << Timestamp(chunkVersion.toLong()) << ChunkType::shard("shard0001")); StatusWith<ChunkType> chunkRes = ChunkType::parseFromConfigBSON(objModNS, collEpoch, collTimestamp); ASSERT_FALSE(chunkRes.isOK()); - BSONObj objModKeys = - BSON(ChunkType::name(OID::gen()) << ChunkType::collectionUUID() << collUuid << "lastmod" - << Timestamp(chunkVersion.toLong()) << "lastmodEpoch" - << chunkVersion.epoch() << ChunkType::shard("shard0001")); + BSONObj objModKeys = BSON(ChunkType::name(OID::gen()) + << ChunkType::collectionUUID() << collUuid << "lastmod" + << Timestamp(chunkVersion.toLong()) << ChunkType::shard("shard0001")); chunkRes = ChunkType::parseFromConfigBSON(objModKeys, collEpoch, collTimestamp); ASSERT_FALSE(chunkRes.isOK()); BSONObj objModShard = BSON( ChunkType::name(OID::gen()) << ChunkType::collectionUUID() << collUuid << ChunkType::min(BSON("a" << 10 << "b" << 10)) - << ChunkType::max(BSON("a" << 20)) << "lastmod" << Timestamp(chunkVersion.toLong()) - << "lastmodEpoch" << chunkVersion.epoch()); + << ChunkType::max(BSON("a" << 20)) << "lastmod" << Timestamp(chunkVersion.toLong())); chunkRes = ChunkType::parseFromConfigBSON(objModShard, collEpoch, collTimestamp); ASSERT_FALSE(chunkRes.isOK()); @@ -255,32 +248,20 @@ TEST(ChunkType, UUIDPresentAndNsMissing) { ASSERT_TRUE(chunkRes.isOK()); } -TEST(ChunkType, NewAndOldChunkVersionFormat) { - const auto collEpoch = OID::gen(); - const auto collTimestamp = Timestamp(1); - - ChunkVersion chunkVersion(1, 2, collEpoch, collTimestamp); +TEST(ChunkType, ParseFromNetworkRequest) { + ChunkVersion chunkVersion(1, 2, OID::gen(), Timestamp(1, 0)); - BSONObj objModOldCVFormat = + auto chunk = assertGet(ChunkType::parseFromNetworkRequest( BSON(ChunkType::name(OID::gen()) << ChunkType::collectionUUID() << mongo::UUID::gen() << ChunkType::min(BSON("a" << 10 << "b" << 10)) << ChunkType::max(BSON("a" << 20)) << "lastmod" - << BSON("v" << Timestamp(chunkVersion.toLong()) << "e" << chunkVersion.epoch() << "t" - << chunkVersion.getTimestamp()) - << ChunkType::shard("shard0001")); - StatusWith<ChunkType> chunkRes = ChunkType::parseFromNetworkRequest(objModOldCVFormat); + << BSON("e" << chunkVersion.epoch() << "t" << chunkVersion.getTimestamp() << "v" + << Timestamp(chunkVersion.toLong())) + << ChunkType::shard("shard0001")))); - ASSERT_TRUE(chunkRes.isOK()); - - BSONObj objModNewCVFormat = BSON( - ChunkType::name(OID::gen()) - << ChunkType::collectionUUID() << mongo::UUID::gen() - << ChunkType::min(BSON("a" << 10 << "b" << 10)) << ChunkType::max(BSON("a" << 20)) - << "lastmod" << Timestamp(chunkVersion.toLong()) << "lastmodEpoch" << chunkVersion.epoch() - << "lastmodTimestamp" << chunkVersion.getTimestamp() << ChunkType::shard("shard0001")); - chunkRes = ChunkType::parseFromNetworkRequest(objModNewCVFormat); - ASSERT_TRUE(chunkRes.isOK()); + ASSERT_EQ("shard0001", chunk.getShard()); + ASSERT_EQ(chunkVersion, chunk.getVersion()); } TEST(ChunkRange, BasicBSONParsing) { |