summaryrefslogtreecommitdiff
path: root/src/mongo/s/balancer/balancer.cpp
diff options
context:
space:
mode:
authorMisha Tyulenev <misha@mongodb.com>2016-08-24 18:05:09 -0400
committerMisha Tyulenev <misha@mongodb.com>2016-08-25 11:57:21 -0400
commit46b33e042de75d801e5fd9f20b74a1c9a249b0c2 (patch)
treeb339c718ee0282cfd04190725369a3b9f154d111 /src/mongo/s/balancer/balancer.cpp
parente589562b858061cf82dd430115c82033203db018 (diff)
downloadmongo-46b33e042de75d801e5fd9f20b74a1c9a249b0c2.tar.gz
SERVER-23996 ShardRegistry::getShard should return a StatusWith<shared_ptr<Shard>>
Diffstat (limited to 'src/mongo/s/balancer/balancer.cpp')
-rw-r--r--src/mongo/s/balancer/balancer.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/mongo/s/balancer/balancer.cpp b/src/mongo/s/balancer/balancer.cpp
index 77402222b2f..6296d42cb88 100644
--- a/src/mongo/s/balancer/balancer.cpp
+++ b/src/mongo/s/balancer/balancer.cpp
@@ -444,10 +444,11 @@ bool Balancer::_checkOIDs(OperationContext* txn) {
return false;
}
- const auto s = shardingContext->shardRegistry()->getShard(txn, shardId);
- if (!s) {
+ auto shardStatus = shardingContext->shardRegistry()->getShard(txn, shardId);
+ if (!shardStatus.isOK()) {
continue;
}
+ const auto s = shardStatus.getValue();
auto result =
uassertStatusOK(s->runCommand(txn,
@@ -474,14 +475,14 @@ bool Balancer::_checkOIDs(OperationContext* txn) {
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(result.commandStatus);
- const auto otherShard = shardingContext->shardRegistry()->getShard(txn, oids[x]);
- if (otherShard) {
- result = uassertStatusOK(
- otherShard->runCommand(txn,
- ReadPreferenceSetting{ReadPreference::PrimaryOnly},
- "admin",
- BSON("features" << 1 << "oidReset" << 1),
- Shard::RetryPolicy::kIdempotent));
+ auto otherShardStatus = shardingContext->shardRegistry()->getShard(txn, oids[x]);
+ if (otherShardStatus.isOK()) {
+ result = uassertStatusOK(otherShardStatus.getValue()->runCommand(
+ txn,
+ ReadPreferenceSetting{ReadPreference::PrimaryOnly},
+ "admin",
+ BSON("features" << 1 << "oidReset" << 1),
+ Shard::RetryPolicy::kIdempotent));
uassertStatusOK(result.commandStatus);
}