diff options
author | Kevin Pulo <kevin.pulo@mongodb.com> | 2017-11-29 03:54:49 +0000 |
---|---|---|
committer | Kevin Pulo <kevin.pulo@mongodb.com> | 2017-12-18 05:47:06 +0000 |
commit | 8a9090c4c59a840639f37c509fd0f2c6af252117 (patch) | |
tree | bc129d2c254438a6a971eb246fa4b6246310096d /src/mongo/db/s | |
parent | 8467708af7fa83f8827362b80f56dab4aad30a41 (diff) | |
download | mongo-8a9090c4c59a840639f37c509fd0f2c6af252117.tar.gz |
SERVER-18138 catalog manager listing methods now return vectors
Diffstat (limited to 'src/mongo/db/s')
-rw-r--r-- | src/mongo/db/s/balancer/balancer_chunk_selection_policy_impl.cpp | 35 | ||||
-rw-r--r-- | src/mongo/db/s/config/configsvr_remove_shard_command.cpp | 14 |
2 files changed, 24 insertions, 25 deletions
diff --git a/src/mongo/db/s/balancer/balancer_chunk_selection_policy_impl.cpp b/src/mongo/db/s/balancer/balancer_chunk_selection_policy_impl.cpp index 3654fcdcd8d..2bf7db8dc9a 100644 --- a/src/mongo/db/s/balancer/balancer_chunk_selection_policy_impl.cpp +++ b/src/mongo/db/s/balancer/balancer_chunk_selection_policy_impl.cpp @@ -83,15 +83,15 @@ StatusWith<DistributionStatus> createCollectionDistributionStatus( shardToChunksMap[chunkEntry->getShardId()].push_back(chunk); } - vector<TagsType> collectionTags; - Status tagsStatus = Grid::get(opCtx)->catalogClient()->getTagsForCollection( - opCtx, chunkMgr->getns(), &collectionTags); - if (!tagsStatus.isOK()) { - return {tagsStatus.code(), + const auto swCollectionTags = + Grid::get(opCtx)->catalogClient()->getTagsForCollection(opCtx, chunkMgr->getns()); + if (!swCollectionTags.isOK()) { + return {swCollectionTags.getStatus().code(), str::stream() << "Unable to load tags for collection " << chunkMgr->getns() << " due to " - << tagsStatus.toString()}; + << swCollectionTags.getStatus().toString()}; } + const auto& collectionTags = swCollectionTags.getValue(); DistributionStatus distribution(NamespaceString(chunkMgr->getns()), std::move(shardToChunksMap)); @@ -191,14 +191,14 @@ StatusWith<SplitInfoVector> BalancerChunkSelectionPolicyImpl::selectChunksToSpli const auto shardStats = std::move(shardStatsStatus.getValue()); - vector<CollectionType> collections; - - Status collsStatus = - Grid::get(opCtx)->catalogClient()->getCollections(opCtx, nullptr, &collections, nullptr); - if (!collsStatus.isOK()) { - return collsStatus; + const auto swCollections = + Grid::get(opCtx)->catalogClient()->getCollections(opCtx, nullptr, nullptr); + if (!swCollections.isOK()) { + return swCollections.getStatus(); } + const auto& collections = swCollections.getValue(); + if (collections.empty()) { return SplitInfoVector{}; } @@ -243,14 +243,15 @@ StatusWith<MigrateInfoVector> BalancerChunkSelectionPolicyImpl::selectChunksToMo return MigrateInfoVector{}; } - vector<CollectionType> collections; - Status collsStatus = - Grid::get(opCtx)->catalogClient()->getCollections(opCtx, nullptr, &collections, nullptr); - if (!collsStatus.isOK()) { - return collsStatus; + const auto swCollections = + Grid::get(opCtx)->catalogClient()->getCollections(opCtx, nullptr, nullptr); + if (!swCollections.isOK()) { + return swCollections.getStatus(); } + const auto& collections = swCollections.getValue(); + if (collections.empty()) { return MigrateInfoVector{}; } diff --git a/src/mongo/db/s/config/configsvr_remove_shard_command.cpp b/src/mongo/db/s/config/configsvr_remove_shard_command.cpp index ad4188d7647..d16fa7950c0 100644 --- a/src/mongo/db/s/config/configsvr_remove_shard_command.cpp +++ b/src/mongo/db/s/config/configsvr_remove_shard_command.cpp @@ -118,9 +118,8 @@ public: const auto shardDrainingStatus = uassertStatusOK(shardingCatalogManager->removeShard(opCtx, shard->getId())); - std::vector<std::string> databases; - uassertStatusOK( - shardingCatalogManager->getDatabasesForShard(opCtx, shard->getId(), &databases)); + std::vector<std::string> databases = + uassertStatusOK(shardingCatalogManager->getDatabasesForShard(opCtx, shard->getId())); // Get BSONObj containing: // 1) note about moving or dropping databases in a shard @@ -149,19 +148,18 @@ public: result.appendElements(dbInfo); break; case ShardDrainingStatus::ONGOING: { - std::vector<ChunkType> chunks; - Status status = Grid::get(opCtx)->catalogClient()->getChunks( + const auto swChunks = Grid::get(opCtx)->catalogClient()->getChunks( opCtx, BSON(ChunkType::shard(shard->getId().toString())), BSONObj(), boost::none, // return all - &chunks, nullptr, repl::ReadConcernLevel::kMajorityReadConcern); - if (!status.isOK()) { - return appendCommandStatus(result, status); + if (!swChunks.isOK()) { + return appendCommandStatus(result, swChunks.getStatus()); } + const auto& chunks = swChunks.getValue(); result.append("msg", "draining ongoing"); result.append("state", "ongoing"); result.append("remaining", |