diff options
author | Lingzhi Deng <lingzhi.deng@mongodb.com> | 2020-08-25 21:45:18 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-27 15:40:00 +0000 |
commit | d3fedc03bb3b2037bc4f2266b4cd106377c217b7 (patch) | |
tree | 3e4f498a1ba9fca30effb239fadd55bf3fc675e6 /src/mongo/db/server_options.h | |
parent | 694ed4153b9d5424b5d169fea5c68f99d4dfb45a (diff) | |
download | mongo-d3fedc03bb3b2037bc4f2266b4cd106377c217b7.tar.gz |
SERVER-50264: Better FCV const correctness
Diffstat (limited to 'src/mongo/db/server_options.h')
-rw-r--r-- | src/mongo/db/server_options.h | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/mongo/db/server_options.h b/src/mongo/db/server_options.h index 9cff03225e1..057133d2124 100644 --- a/src/mongo/db/server_options.h +++ b/src/mongo/db/server_options.h @@ -232,15 +232,7 @@ struct ServerGlobalParams { return _version.load(); } - void reset() { - _version.store(Version::kUnsetDefault44Behavior); - } - - void setVersion(Version version) { - return _version.store(version); - } - - bool isLessThanOrEqualTo(Version version, Version* versionReturn = nullptr) { + bool isLessThanOrEqualTo(Version version, Version* versionReturn = nullptr) const { Version currentVersion = getVersion(); if (versionReturn != nullptr) { *versionReturn = currentVersion; @@ -248,7 +240,7 @@ struct ServerGlobalParams { return currentVersion <= version; } - bool isGreaterThanOrEqualTo(Version version, Version* versionReturn = nullptr) { + bool isGreaterThanOrEqualTo(Version version, Version* versionReturn = nullptr) const { Version currentVersion = getVersion(); if (versionReturn != nullptr) { *versionReturn = currentVersion; @@ -256,7 +248,7 @@ struct ServerGlobalParams { return currentVersion >= version; } - bool isLessThan(Version version, Version* versionReturn = nullptr) { + bool isLessThan(Version version, Version* versionReturn = nullptr) const { Version currentVersion = getVersion(); if (versionReturn != nullptr) { *versionReturn = currentVersion; @@ -264,7 +256,7 @@ struct ServerGlobalParams { return currentVersion < version; } - bool isGreaterThan(Version version, Version* versionReturn = nullptr) { + bool isGreaterThan(Version version, Version* versionReturn = nullptr) const { Version currentVersion = getVersion(); if (versionReturn != nullptr) { *versionReturn = currentVersion; @@ -273,17 +265,28 @@ struct ServerGlobalParams { } // This function is to be used for generic FCV references only, and not for FCV-gating. - bool isUpgradingOrDowngrading(boost::optional<Version> version = boost::none) { + bool isUpgradingOrDowngrading(boost::optional<Version> version = boost::none) const { if (version == boost::none) { version = getVersion(); } return version != kLatest && version != kLastContinuous && version != kLastLTS; } + void reset() { + _version.store(Version::kUnsetDefault44Behavior); + } + + void setVersion(Version version) { + return _version.store(version); + } + private: AtomicWord<Version> _version{Version::kUnsetDefault44Behavior}; - } featureCompatibility; + } mutableFeatureCompatibility; + + // Const reference for featureCompatibilityVersion checks. + const FeatureCompatibility& featureCompatibility = mutableFeatureCompatibility; // Feature validation differs depending on the role of a mongod in a replica set. Replica set // primaries can accept user-initiated writes and validate based on the feature compatibility |