summaryrefslogtreecommitdiff
path: root/src/mongo/s/balancer_policy.cpp
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2015-05-20 07:53:40 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2015-05-20 07:53:40 -0400
commitb59643cbf83cb8f31d1d1df99269885caf03724e (patch)
tree9aea56cebafa2dd3c3f258d774197a2c2c794910 /src/mongo/s/balancer_policy.cpp
parent1b28b6142589ec2ef578d9d22fb3f55b3b04a5e7 (diff)
downloadmongo-b59643cbf83cb8f31d1d1df99269885caf03724e.tar.gz
Revert "SERVER-18124 Move tags loading to the catalog manager"
This reverts commit a92746a39fe7d45983d5fd5f7619d2c0005ce884.
Diffstat (limited to 'src/mongo/s/balancer_policy.cpp')
-rw-r--r--src/mongo/s/balancer_policy.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/mongo/s/balancer_policy.cpp b/src/mongo/s/balancer_policy.cpp
index 42f0268b733..c3c715354b3 100644
--- a/src/mongo/s/balancer_policy.cpp
+++ b/src/mongo/s/balancer_policy.cpp
@@ -38,9 +38,9 @@
#include "mongo/client/connpool.h"
#include "mongo/s/catalog/catalog_manager.h"
#include "mongo/s/catalog/type_shard.h"
-#include "mongo/s/catalog/type_tags.h"
#include "mongo/s/chunk_manager.h"
#include "mongo/s/grid.h"
+#include "mongo/s/type_tags.h"
#include "mongo/util/log.h"
#include "mongo/util/stringutils.h"
@@ -305,6 +305,37 @@ namespace mongo {
}
}
+ StatusWith<string> DistributionStatus::getTagForSingleChunk(const string& configServer,
+ const string& ns,
+ const ChunkType& chunk) {
+ BSONObj tagRangeDoc;
+
+ try {
+ ScopedDbConnection conn(configServer, 30);
+
+ Query query(QUERY(TagsType::ns(ns)
+ << TagsType::min() << BSON("$lte" << chunk.getMin())
+ << TagsType::max() << BSON("$gte" << chunk.getMax())));
+ tagRangeDoc = conn->findOne(TagsType::ConfigNS, query);
+ conn.done();
+ }
+ catch (const DBException& excep) {
+ return StatusWith<string>(excep.toStatus());
+ }
+
+ if (tagRangeDoc.isEmpty()) {
+ return StatusWith<string>("");
+ }
+
+ TagsType tagRange;
+ string errMsg;
+ if (!tagRange.parseBSON(tagRangeDoc, &errMsg)) {
+ return StatusWith<string>(ErrorCodes::FailedToParse, errMsg);
+ }
+
+ return StatusWith<string>(tagRange.getTag());
+ }
+
MigrateInfo* BalancerPolicy::balance( const string& ns,
const DistributionStatus& distribution,
int balancedLastTime ) {