diff options
author | Jess Fan <jess.fan@10gen.com> | 2016-07-28 20:15:02 -0400 |
---|---|---|
committer | Jess Fan <jess.fan@10gen.com> | 2016-08-11 11:40:42 -0400 |
commit | be8b9869132ed44b25a909476abad03d9254fde9 (patch) | |
tree | 9a0e3df98699293ea5a2a40d5851b3cf3fa53756 /src/mongo/s/request_types/merge_chunk_request_type.cpp | |
parent | eb15955c67b8a13455b91a6848f8750447fb0f44 (diff) | |
download | mongo-be8b9869132ed44b25a909476abad03d9254fde9.tar.gz |
SERVER-25000 Built _configsvrMergeChunk wrapper around applyOps
Diffstat (limited to 'src/mongo/s/request_types/merge_chunk_request_type.cpp')
-rw-r--r-- | src/mongo/s/request_types/merge_chunk_request_type.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/mongo/s/request_types/merge_chunk_request_type.cpp b/src/mongo/s/request_types/merge_chunk_request_type.cpp index 75f19e7f610..508bf9b247d 100644 --- a/src/mongo/s/request_types/merge_chunk_request_type.cpp +++ b/src/mongo/s/request_types/merge_chunk_request_type.cpp @@ -35,6 +35,7 @@ namespace mongo { +using std::string; using std::vector; namespace { @@ -42,18 +43,21 @@ namespace { const char kConfigsvrMergeChunk[] = "_configsvrMergeChunk"; const char kCollEpoch[] = "collEpoch"; const char kChunkBoundaries[] = "chunkBoundaries"; +const char kShardName[] = "shard"; } // unnamed namespace MergeChunkRequest::MergeChunkRequest(NamespaceString nss, OID epoch, - vector<BSONObj> chunkBoundaries) + vector<BSONObj> chunkBoundaries, + string shardName) : _nss(std::move(nss)), _epoch(std::move(epoch)), - _chunkBoundaries(std::move(chunkBoundaries)) {} + _chunkBoundaries(std::move(chunkBoundaries)), + _shardName(std::move(shardName)) {} StatusWith<MergeChunkRequest> MergeChunkRequest::parseFromConfigCommand(const BSONObj& cmdObj) { - std::string ns; + string ns; auto parseNamespaceStatus = bsonExtractStringField(cmdObj, kConfigsvrMergeChunk, &ns); if (!parseNamespaceStatus.isOK()) { @@ -82,8 +86,15 @@ StatusWith<MergeChunkRequest> MergeChunkRequest::parseFromConfigCommand(const BS } } - auto request = - MergeChunkRequest(NamespaceString(ns), std::move(epoch), std::move(chunkBoundaries)); + string shardName; + auto parseShardNameStatus = bsonExtractStringField(cmdObj, kShardName, &shardName); + + if (!parseShardNameStatus.isOK()) { + return parseShardNameStatus; + } + + auto request = MergeChunkRequest( + NamespaceString(ns), std::move(epoch), std::move(chunkBoundaries), std::move(shardName)); Status validationStatus = request._validate(); if (!validationStatus.isOK()) { return validationStatus; @@ -111,6 +122,7 @@ void MergeChunkRequest::appendAsConfigCommand(BSONObjBuilder* cmdBuilder) { chunkBoundariesArray.append(chunkBoundary); } } + cmdBuilder->append(kShardName, _shardName); } const NamespaceString& MergeChunkRequest::getNamespace() const { @@ -125,6 +137,10 @@ const vector<BSONObj>& MergeChunkRequest::getChunkBoundaries() const { return _chunkBoundaries; } +const string& MergeChunkRequest::getShardName() const { + return _shardName; +} + Status MergeChunkRequest::_validate() { if (!getNamespace().isValid()) { return Status(ErrorCodes::InvalidNamespace, |