summaryrefslogtreecommitdiff
path: root/src/mongo/s/balance.cpp
diff options
context:
space:
mode:
authorSiyuan Zhou <visualzhou@gmail.com>2015-06-26 20:54:55 -0400
committerSiyuan Zhou <visualzhou@gmail.com>2015-06-26 20:54:55 -0400
commit8910277205b7b1cc52e4650c38172f801c522597 (patch)
treea4d5b3009e1ce115efa6d988b7ef873c13adbc4a /src/mongo/s/balance.cpp
parentacd34c682c9e602ab1ed65d517b79a4bb575bf6a (diff)
downloadmongo-8910277205b7b1cc52e4650c38172f801c522597.tar.gz
Revert "SERVER-19004 Get rid of Shard::runCommand"
This reverts commit ce22d7ea21ad0f529b0dbb4e0b9264d1a68637ff.
Diffstat (limited to 'src/mongo/s/balance.cpp')
-rw-r--r--src/mongo/s/balance.cpp24
1 files changed, 5 insertions, 19 deletions
diff --git a/src/mongo/s/balance.cpp b/src/mongo/s/balance.cpp
index 7b836bb26d8..29444e27953 100644
--- a/src/mongo/s/balance.cpp
+++ b/src/mongo/s/balance.cpp
@@ -35,7 +35,6 @@
#include <algorithm>
#include "mongo/client/dbclientcursor.h"
-#include "mongo/client/remote_command_targeter.h"
#include "mongo/db/client.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/namespace_string.h"
@@ -244,7 +243,6 @@ static BSONObj _buildDetails(bool didError,
builder.append("candidateChunks", candidateChunks);
builder.append("chunksMoved", chunksMoved);
}
-
return builder.obj();
}
@@ -261,11 +259,7 @@ bool Balancer::_checkOIDs() {
continue;
}
- const auto shardHost = uassertStatusOK(
- s->getTargeter()->findHost({ReadPreference::PrimaryOnly, TagSet::primaryOnly()}));
-
- BSONObj f = uassertStatusOK(
- grid.shardRegistry()->runCommand(shardHost, "admin", BSON("features" << 1)));
+ BSONObj f = s->runCommand("admin", "features");
if (f["oidMachine"].isNumber()) {
int x = f["oidMachine"].numberInt();
if (oids.count(x) == 0) {
@@ -273,26 +267,18 @@ bool Balancer::_checkOIDs() {
} else {
log() << "error: 2 machines have " << x << " as oid machine piece: " << shardId
<< " and " << oids[x];
-
- uassertStatusOK(grid.shardRegistry()->runCommand(
- shardHost, "admin", BSON("features" << 1 << "oidReset" << 1)));
+ s->runCommand("admin", BSON("features" << 1 << "oidReset" << 1));
const auto otherShard = grid.shardRegistry()->getShard(oids[x]);
if (otherShard) {
- const auto otherShardHost = uassertStatusOK(otherShard->getTargeter()->findHost(
- {ReadPreference::PrimaryOnly, TagSet::primaryOnly()}));
-
- uassertStatusOK(grid.shardRegistry()->runCommand(
- otherShardHost, "admin", BSON("features" << 1 << "oidReset" << 1)));
+ otherShard->runCommand("admin", BSON("features" << 1 << "oidReset" << 1));
}
-
return false;
}
} else {
log() << "warning: oidMachine not set on: " << s->toString();
}
}
-
return true;
}
@@ -502,8 +488,8 @@ bool Balancer::_init() {
void Balancer::run() {
Client::initThread("Balancer");
- // This is the body of a BackgroundJob so if we throw here we're basically ending the balancer
- // thread prematurely.
+ // This is the body of a BackgroundJob so if we throw here we're basically ending the
+ // balancer thread prematurely.
while (!inShutdown()) {
if (!_init()) {
log() << "will retry to initialize balancer in one minute";