diff options
author | Randolph Tan <randolph@10gen.com> | 2016-04-22 14:10:33 -0400 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2016-05-05 15:45:46 -0400 |
commit | d5b670a01622ff5b9cd8dc1a988321022948182b (patch) | |
tree | 3eaf298e2815f11c5fefbaddec9cf0011efd0755 /src/mongo/db/s/type_shard_identity.cpp | |
parent | 9f91d422fc826d08b8eca8d323276c22d63ba436 (diff) | |
download | mongo-d5b670a01622ff5b9cd8dc1a988321022948182b.tar.gz |
SERVER-23765 Update config string of shardIdentity document
Diffstat (limited to 'src/mongo/db/s/type_shard_identity.cpp')
-rw-r--r-- | src/mongo/db/s/type_shard_identity.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/db/s/type_shard_identity.cpp b/src/mongo/db/s/type_shard_identity.cpp index f776e8cd573..7ef675ad334 100644 --- a/src/mongo/db/s/type_shard_identity.cpp +++ b/src/mongo/db/s/type_shard_identity.cpp @@ -30,16 +30,22 @@ #include "mongo/db/s/type_shard_identity.h" +#include "mongo/bson/bsonobjbuilder.h" #include "mongo/bson/util/bson_extract.h" #include "mongo/util/assert_util.h" namespace mongo { const std::string ShardIdentityType::IdName("shardIdentity"); + +namespace { + const BSONField<std::string> configsvrConnString("configsvrConnectionString"); const BSONField<std::string> shardName("shardName"); const BSONField<OID> clusterId("clusterId"); +} // unnamed namespace + StatusWith<ShardIdentityType> ShardIdentityType::fromBSON(const BSONObj& source) { if (!source.hasField("_id")) { return {ErrorCodes::NoSuchKey, @@ -198,4 +204,12 @@ void ShardIdentityType::setClusterId(OID clusterId) { _clusterId = std::move(clusterId); } +BSONObj ShardIdentityType::createConfigServerUpdateObject(const std::string& newConnString) { + BSONObjBuilder builder; + BSONObjBuilder setConfigBuilder(builder.subobjStart("$set")); + setConfigBuilder.append(configsvrConnString(), newConnString); + setConfigBuilder.doneFast(); + return builder.obj(); +} + } // namespace mongo |