diff options
author | Randolph Tan <randolph@10gen.com> | 2016-04-26 17:35:45 -0400 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2016-05-05 10:49:28 -0400 |
commit | 359f97d52340e356324e2bf3b724fad6a2383ea1 (patch) | |
tree | 03df941994a2d570a2ef58d35ff4a51b8fae8b38 /src/mongo/db/mongod_options.cpp | |
parent | f7a46a118288ba0ce45c7664777ea0e89c2eb845 (diff) | |
download | mongo-359f97d52340e356324e2bf3b724fad6a2383ea1.tar.gz |
SERVER-22664 Add _overrideShardIdentity configuration for cloud backup service
Diffstat (limited to 'src/mongo/db/mongod_options.cpp')
-rw-r--r-- | src/mongo/db/mongod_options.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp index a31e165af34..59ceb56e187 100644 --- a/src/mongo/db/mongod_options.cpp +++ b/src/mongo/db/mongod_options.cpp @@ -36,6 +36,7 @@ #include <vector> #include "mongo/base/status.h" +#include "mongo/bson/json.h" #include "mongo/bson/util/builder.h" #include "mongo/config.h" #include "mongo/db/db.h" @@ -461,6 +462,17 @@ Status addMongodOptions(moe::OptionSection* options) { .setSources(moe::SourceYAMLConfig) .format("(:?configsvr)|(:?shardsvr)", "(configsvr/shardsvr)"); + sharding_options + .addOptionChaining( + "sharding._overrideShardIdentity", + "", + moe::String, + "overrides the shardIdentity document settings stored in the local storage with " + "a MongoDB Extended JSON document in string format") + .setSources(moe::SourceYAMLConfig) + .incompatibleWith("configsvr") + .requires("storage.queryableBackupMode"); + sharding_options.addOptionChaining( "noMoveParanoia", "noMoveParanoia", @@ -669,7 +681,21 @@ Status validateMongodOptions(const moe::Environment& params) { << disallowedOption); } } + + bool isClusterRoleShard = false; + if (params.count("sharding.clusterRole")) { + auto clusterRole = params["sharding.clusterRole"].as<std::string>(); + isClusterRoleShard = (clusterRole == "shardsvr"); + } + + if ((isClusterRoleShard || params.count("shardsvr")) && + !params.count("sharding._overrideShardIdentity")) { + return Status( + ErrorCodes::BadValue, + "shardsvr cluster role with queryableBackupMode requires _overrideShardIdentity"); + } } + return Status::OK(); } @@ -1239,6 +1265,17 @@ Status storeMongodOptions(const moe::Environment& params, const std::vector<std: serverGlobalParams.moveParanoia = params["sharding.archiveMovedChunks"].as<bool>(); } + if (params.count("sharding._overrideShardIdentity")) { + auto docAsString = params["sharding._overrideShardIdentity"].as<std::string>(); + + try { + serverGlobalParams.overrideShardIdentity = fromjson(docAsString); + } catch (const DBException& exception) { + return exception.toStatus( + "Error encountered while parsing _overrideShardIdentity JSON document"); + } + } + if (params.count("pairwith") || params.count("arbiter") || params.count("opIdMem")) { return Status(ErrorCodes::BadValue, "****\n" |