summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2022-01-20 09:20:51 +0100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-01-24 14:44:28 +0000
commit3ce4e1938871cfa86599cf37c871542a7f4ca4c4 (patch)
treef659eb8120daa83b8b21ca25ffee25704474b171 /src/mongo
parent14c6f826f2d54a9d6928009be3627bff948ceb39 (diff)
downloadmongo-3ce4e1938871cfa86599cf37c871542a7f4ca4c4.tar.gz
SERVER-62783 Move the version parsing for ShardCollectionType out of ChunkVersion
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/s/type_shard_collection.cpp4
-rw-r--r--src/mongo/db/s/type_shard_collection.h9
-rw-r--r--src/mongo/db/s/type_shard_collection.idl12
-rw-r--r--src/mongo/s/chunk_version.cpp21
-rw-r--r--src/mongo/s/chunk_version.h22
-rw-r--r--src/mongo/s/chunk_version.idl8
6 files changed, 38 insertions, 38 deletions
diff --git a/src/mongo/db/s/type_shard_collection.cpp b/src/mongo/db/s/type_shard_collection.cpp
index 66ab2759fbb..6033510b6d3 100644
--- a/src/mongo/db/s/type_shard_collection.cpp
+++ b/src/mongo/db/s/type_shard_collection.cpp
@@ -35,13 +35,13 @@ namespace mongo {
ShardCollectionType::ShardCollectionType(NamespaceString nss,
OID epoch,
- Timestamp creationTime,
+ Timestamp timestamp,
UUID uuid,
KeyPattern keyPattern,
bool unique)
: ShardCollectionTypeBase(std::move(nss),
std::move(epoch),
- std::move(creationTime),
+ std::move(timestamp),
std::move(uuid),
std::move(keyPattern),
unique) {}
diff --git a/src/mongo/db/s/type_shard_collection.h b/src/mongo/db/s/type_shard_collection.h
index f6a86b0b388..bb05d1bd7ed 100644
--- a/src/mongo/db/s/type_shard_collection.h
+++ b/src/mongo/db/s/type_shard_collection.h
@@ -70,20 +70,15 @@ public:
using ShardCollectionTypeBase::setAllowAutoSplit;
using ShardCollectionTypeBase::setDefaultCollation;
using ShardCollectionTypeBase::setEnterCriticalSectionCounter;
- using ShardCollectionTypeBase::setEpoch;
using ShardCollectionTypeBase::setKeyPattern;
- using ShardCollectionTypeBase::setLastRefreshedCollectionVersion;
using ShardCollectionTypeBase::setMaxChunkSizeBytes;
- using ShardCollectionTypeBase::setNss;
using ShardCollectionTypeBase::setRefreshing;
using ShardCollectionTypeBase::setReshardingFields;
using ShardCollectionTypeBase::setTimeseriesFields;
- using ShardCollectionTypeBase::setUnique;
- using ShardCollectionTypeBase::setUuid;
ShardCollectionType(NamespaceString nss,
OID epoch,
- Timestamp creationTime,
+ Timestamp timestamp,
UUID uuid,
KeyPattern keyPattern,
bool unique);
@@ -97,7 +92,7 @@ public:
BSONObj toBSON() const;
bool getAllowMigrations() const {
- return getPre50CompatibleAllowMigrations().get_value_or(true);
+ return getPre50CompatibleAllowMigrations().value_or(true);
}
void setAllowMigrations(bool allowMigrations);
diff --git a/src/mongo/db/s/type_shard_collection.idl b/src/mongo/db/s/type_shard_collection.idl
index fbc5cd6ac8f..0ecdae5e50f 100644
--- a/src/mongo/db/s/type_shard_collection.idl
+++ b/src/mongo/db/s/type_shard_collection.idl
@@ -81,6 +81,15 @@ imports:
- "mongo/s/resharding/type_collection_fields.idl"
- "mongo/s/type_collection_common_types.idl"
+types:
+ ChunkVersionLegacy:
+ bson_serialization_type: any
+ description: "An object representing a chunk version for a collection. Ignores the epoch
+ component in the chunk version for legacy reasons."
+ cpp_type: ChunkVersion
+ serializer: ChunkVersion::serialiseMajorMinorVersionOnlyForShardCollectionType
+ deserializer: ChunkVersion::parseMajorMinorVersionOnlyFromShardCollectionType
+
structs:
ShardCollectionTypeBase:
description: "Represents the layout and contents of documents contained in the shard
@@ -156,7 +165,8 @@ structs:
optional: true
allowAutoSplit:
type: bool
- description: "Specifies whether the auto-splitter should be running or not for this collection."
+ description: "Specifies whether the auto-splitter should be running or not for this
+ collection."
default: true
allowMigrations:
cpp_name: pre50CompatibleAllowMigrations
diff --git a/src/mongo/s/chunk_version.cpp b/src/mongo/s/chunk_version.cpp
index 3379d433f35..fd71e7270f8 100644
--- a/src/mongo/s/chunk_version.cpp
+++ b/src/mongo/s/chunk_version.cpp
@@ -184,13 +184,26 @@ BSONObj ChunkVersion::toBSON() const {
return b.arr();
}
-void ChunkVersion::legacyToBSON(StringData field, BSONObjBuilder* out) const {
- out->appendTimestamp(field, this->toLong());
-}
-
std::string ChunkVersion::toString() const {
return str::stream() << majorVersion() << "|" << minorVersion() << "||" << _epoch << "||"
<< _timestamp.toString();
}
+ChunkVersion ChunkVersion::parseMajorMinorVersionOnlyFromShardCollectionType(
+ const BSONElement& element) {
+ uassert(ErrorCodes::TypeMismatch,
+ str::stream() << "Invalid type " << element.type()
+ << " for version major and minor part.",
+ element.type() == bsonTimestamp || element.type() == Date);
+
+ ChunkVersion version;
+ version._combined = element._numberLong();
+ return version;
+}
+
+void ChunkVersion::serialiseMajorMinorVersionOnlyForShardCollectionType(StringData field,
+ BSONObjBuilder* out) const {
+ out->appendTimestamp(field, toLong());
+}
+
} // namespace mongo
diff --git a/src/mongo/s/chunk_version.h b/src/mongo/s/chunk_version.h
index 136533ca791..96ea3864b35 100644
--- a/src/mongo/s/chunk_version.h
+++ b/src/mongo/s/chunk_version.h
@@ -93,16 +93,6 @@ public:
}
/**
- * NOTE: This format should not be used. Use fromBSONThrowing instead.
- *
- * A throwing version of 'parseLegacyWithField' to resolve a compatibility issue with the
- * ShardCollectionType IDL type.
- */
- static ChunkVersion legacyFromBSONThrowing(const BSONElement& element) {
- return uassertStatusOK(parseLegacyWithField(element.wrap(), element.fieldNameStringData()));
- }
-
- /**
* NOTE: This format is being phased out. Use parseWithField instead.
*
* Parses the BSON formatted by appendLegacyWithField. If the field is missing, returns
@@ -265,14 +255,14 @@ public:
appendWithField(builder, fieldName);
}
- /**
- * NOTE: This format serializes chunk version as a timestamp (without the epoch) for
- * legacy reasons.
- */
- void legacyToBSON(StringData field, BSONObjBuilder* builder) const;
-
std::string toString() const;
+ // Methods that are here for the purposes of parsing of ShardCollectionType only
+ static ChunkVersion parseMajorMinorVersionOnlyFromShardCollectionType(
+ const BSONElement& element);
+ void serialiseMajorMinorVersionOnlyForShardCollectionType(StringData field,
+ BSONObjBuilder* builder) const;
+
private:
uint64_t _combined;
OID _epoch;
diff --git a/src/mongo/s/chunk_version.idl b/src/mongo/s/chunk_version.idl
index 82ea4f5333c..e2e50aadcff 100644
--- a/src/mongo/s/chunk_version.idl
+++ b/src/mongo/s/chunk_version.idl
@@ -42,11 +42,3 @@ types:
cpp_type: ChunkVersion
serializer: ChunkVersion::toBSON
deserializer: ChunkVersion::fromBSONThrowing
-
- ChunkVersionLegacy:
- bson_serialization_type: any
- description: An object representing a chunk version for a collection. Ignores the epoch
- component in the chunk version for legacy reasons.
- cpp_type: ChunkVersion
- serializer: ChunkVersion::legacyToBSON
- deserializer: ChunkVersion::legacyFromBSONThrowing