diff options
author | Lingzhi Deng <lingzhi.deng@mongodb.com> | 2019-11-12 19:19:54 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-11-12 19:19:54 +0000 |
commit | 0dc87ca907a725308d21378dcf65380a64f31364 (patch) | |
tree | 2477f6f5e6fea593f61d9c5b44ea398630bfd3a5 /src/mongo/s | |
parent | 73c90b784455b3d4a0fd66919257ae73afa3b20b (diff) | |
download | mongo-0dc87ca907a725308d21378dcf65380a64f31364.tar.gz |
SERVER-43854: Make WriteConcernOptions::parse a static function returning StatusWith<WriteConcernOptions>
Diffstat (limited to 'src/mongo/s')
-rw-r--r-- | src/mongo/s/catalog/sharding_catalog_client_impl.cpp | 7 | ||||
-rw-r--r-- | src/mongo/s/request_types/migration_secondary_throttle_options.cpp | 22 |
2 files changed, 12 insertions, 17 deletions
diff --git a/src/mongo/s/catalog/sharding_catalog_client_impl.cpp b/src/mongo/s/catalog/sharding_catalog_client_impl.cpp index 4ced819df8a..04d88a11834 100644 --- a/src/mongo/s/catalog/sharding_catalog_client_impl.cpp +++ b/src/mongo/s/catalog/sharding_catalog_client_impl.cpp @@ -594,10 +594,11 @@ bool ShardingCatalogClientImpl::runUserManagementWriteCommand(OperationContext* BSONElement writeConcernElement = cmdObj[WriteConcernOptions::kWriteConcernField]; bool initialCmdHadWriteConcern = !writeConcernElement.eoo(); if (initialCmdHadWriteConcern) { - Status status = writeConcern.parse(writeConcernElement.Obj()); - if (!status.isOK()) { - return CommandHelpers::appendCommandStatusNoThrow(*result, status); + auto sw = WriteConcernOptions::parse(writeConcernElement.Obj()); + if (!sw.isOK()) { + return CommandHelpers::appendCommandStatusNoThrow(*result, sw.getStatus()); } + writeConcern = sw.getValue(); if (!(writeConcern.wNumNodes == 1 || writeConcern.wMode == WriteConcernOptions::kMajority)) { diff --git a/src/mongo/s/request_types/migration_secondary_throttle_options.cpp b/src/mongo/s/request_types/migration_secondary_throttle_options.cpp index a6540d47ac7..d739671b1e3 100644 --- a/src/mongo/s/request_types/migration_secondary_throttle_options.cpp +++ b/src/mongo/s/request_types/migration_secondary_throttle_options.cpp @@ -108,10 +108,9 @@ StatusWith<MigrationSecondaryThrottleOptions> MigrationSecondaryThrottleOptions: invariant(writeConcernBSON.is_initialized()); // Make sure the write concern parses correctly - WriteConcernOptions writeConcern; - Status status = writeConcern.parse(*writeConcernBSON); - if (!status.isOK()) { - return status; + auto sw = WriteConcernOptions::parse(*writeConcernBSON); + if (!sw.isOK()) { + return sw.getStatus(); } return MigrationSecondaryThrottleOptions(secondaryThrottle, std::move(writeConcernBSON)); @@ -138,23 +137,18 @@ MigrationSecondaryThrottleOptions::createFromBalancerConfig(const BSONObj& obj) if (!status.isOK()) return status; - WriteConcernOptions writeConcern; - Status writeConcernParseStatus = writeConcern.parse(elem.Obj()); - if (!writeConcernParseStatus.isOK()) { - return writeConcernParseStatus; + auto sw = WriteConcernOptions::parse(elem.Obj()); + if (!sw.isOK()) { + return sw.getStatus(); } - - return MigrationSecondaryThrottleOptions::createWithWriteConcern(writeConcern); + return MigrationSecondaryThrottleOptions::createWithWriteConcern(sw.getValue()); } WriteConcernOptions MigrationSecondaryThrottleOptions::getWriteConcern() const { invariant(_secondaryThrottle != kOff); invariant(_writeConcernBSON); - WriteConcernOptions writeConcern; - fassert(34414, writeConcern.parse(*_writeConcernBSON)); - - return writeConcern; + return fassert(34414, WriteConcernOptions::parse(*_writeConcernBSON)); } void MigrationSecondaryThrottleOptions::append(BSONObjBuilder* builder) const { |