diff options
author | Grace Luong <grace.luong@mongodb.com> | 2020-07-24 22:35:32 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-07-25 02:25:37 +0000 |
commit | 0045dc81dfadc33d60130dbb575a7a0a74305924 (patch) | |
tree | 4b2e3f8dbd3351e8cfb9ba2574d6384c7bba8126 /src/mongo/db/server_options.h | |
parent | 32b754043dd3af1e45e9931b231fb4d98f1730b5 (diff) | |
download | mongo-0045dc81dfadc33d60130dbb575a7a0a74305924.tar.gz |
SERVER-49070: add and use FCV gating helpers
Diffstat (limited to 'src/mongo/db/server_options.h')
-rw-r--r-- | src/mongo/db/server_options.h | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/mongo/db/server_options.h b/src/mongo/db/server_options.h index 2b2f88dee47..4d239097d91 100644 --- a/src/mongo/db/server_options.h +++ b/src/mongo/db/server_options.h @@ -242,8 +242,44 @@ struct ServerGlobalParams { return _version.store(version); } - bool isVersion(Version version) { - return _version.load() == version; + bool isLessThanOrEqualTo(Version version, Version* versionReturn = nullptr) { + Version currentVersion = getVersion(); + if (versionReturn != nullptr) { + *versionReturn = currentVersion; + } + return currentVersion <= version; + } + + bool isGreaterThanOrEqualTo(Version version, Version* versionReturn = nullptr) { + Version currentVersion = getVersion(); + if (versionReturn != nullptr) { + *versionReturn = currentVersion; + } + return currentVersion >= version; + } + + bool isLessThan(Version version, Version* versionReturn = nullptr) { + Version currentVersion = getVersion(); + if (versionReturn != nullptr) { + *versionReturn = currentVersion; + } + return currentVersion < version; + } + + bool isGreaterThan(Version version, Version* versionReturn = nullptr) { + Version currentVersion = getVersion(); + if (versionReturn != nullptr) { + *versionReturn = currentVersion; + } + return currentVersion > version; + } + + // This function is to be used for generic FCV references only, and not for FCV-gating. + bool isUpgradingOrDowngrading(boost::optional<Version> version = boost::none) { + if (version == boost::none) { + version = getVersion(); + } + return version != kLatest && version != kLastContinuous && version != kLastLTS; } private: |