diff options
author | Pol Pinol Castuera <pol.pinol@mongodb.com> | 2023-01-24 15:43:57 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-01-24 17:14:50 +0000 |
commit | 87109d37572d6607caba79630f7d8f568b70f79e (patch) | |
tree | 53f331f7c9c5b542e569f53a389ebf002b6bfa9e /src/mongo/s/catalog | |
parent | 1acba68fc3cb501df6e9a23f1f041e1043edc101 (diff) | |
download | mongo-87109d37572d6607caba79630f7d8f568b70f79e.tar.gz |
SERVER-72669 Get collections sorted by namespace directly from the configsvr
Diffstat (limited to 'src/mongo/s/catalog')
5 files changed, 18 insertions, 7 deletions
diff --git a/src/mongo/s/catalog/sharding_catalog_client.h b/src/mongo/s/catalog/sharding_catalog_client.h index cc03a2baa28..d93e8e9bddf 100644 --- a/src/mongo/s/catalog/sharding_catalog_client.h +++ b/src/mongo/s/catalog/sharding_catalog_client.h @@ -132,11 +132,14 @@ public: /** * Retrieves all collections under a specified database (or in the system). If the dbName * parameter is empty, returns all collections. + * + * @param sort Fields to use for sorting the results. If empty, no sorting is performed. */ virtual std::vector<CollectionType> getCollections( OperationContext* opCtx, StringData db, - repl::ReadConcernLevel readConcernLevel = repl::ReadConcernLevel::kMajorityReadConcern) = 0; + repl::ReadConcernLevel readConcernLevel = repl::ReadConcernLevel::kMajorityReadConcern, + const BSONObj& sort = BSONObj()) = 0; /** * Returns the set of collections for the specified database, which have been marked as sharded. diff --git a/src/mongo/s/catalog/sharding_catalog_client_impl.cpp b/src/mongo/s/catalog/sharding_catalog_client_impl.cpp index 9a167bdad50..9afaf5e38ff 100644 --- a/src/mongo/s/catalog/sharding_catalog_client_impl.cpp +++ b/src/mongo/s/catalog/sharding_catalog_client_impl.cpp @@ -743,7 +743,10 @@ CollectionType ShardingCatalogClientImpl::getCollection(OperationContext* opCtx, } std::vector<CollectionType> ShardingCatalogClientImpl::getCollections( - OperationContext* opCtx, StringData dbName, repl::ReadConcernLevel readConcernLevel) { + OperationContext* opCtx, + StringData dbName, + repl::ReadConcernLevel readConcernLevel, + const BSONObj& sort) { BSONObjBuilder b; if (!dbName.empty()) b.appendRegex(CollectionType::kNssFieldName, "^{}\\."_format(pcre_util::quoteMeta(dbName))); @@ -753,7 +756,7 @@ std::vector<CollectionType> ShardingCatalogClientImpl::getCollections( readConcernLevel, CollectionType::ConfigNS, b.obj(), - BSONObj(), + sort, boost::none)) .value; std::vector<CollectionType> collections; @@ -766,7 +769,7 @@ std::vector<CollectionType> ShardingCatalogClientImpl::getCollections( std::vector<NamespaceString> ShardingCatalogClientImpl::getAllShardedCollectionsForDb( OperationContext* opCtx, StringData dbName, repl::ReadConcernLevel readConcern) { - auto collectionsOnConfig = getCollections(opCtx, dbName, readConcern); + auto collectionsOnConfig = getCollections(opCtx, dbName, readConcern, BSONObj()); std::vector<NamespaceString> collectionsToReturn; collectionsToReturn.reserve(collectionsOnConfig.size()); diff --git a/src/mongo/s/catalog/sharding_catalog_client_impl.h b/src/mongo/s/catalog/sharding_catalog_client_impl.h index 0a58457412b..49006332c4c 100644 --- a/src/mongo/s/catalog/sharding_catalog_client_impl.h +++ b/src/mongo/s/catalog/sharding_catalog_client_impl.h @@ -82,7 +82,8 @@ public: std::vector<CollectionType> getCollections(OperationContext* opCtx, StringData db, - repl::ReadConcernLevel readConcernLevel) override; + repl::ReadConcernLevel readConcernLevel, + const BSONObj& sort) override; std::vector<NamespaceString> getAllShardedCollectionsForDb( OperationContext* opCtx, StringData dbName, repl::ReadConcernLevel readConcern) override; diff --git a/src/mongo/s/catalog/sharding_catalog_client_mock.cpp b/src/mongo/s/catalog/sharding_catalog_client_mock.cpp index 162d445aa31..47c96b6c81c 100644 --- a/src/mongo/s/catalog/sharding_catalog_client_mock.cpp +++ b/src/mongo/s/catalog/sharding_catalog_client_mock.cpp @@ -69,7 +69,10 @@ CollectionType ShardingCatalogClientMock::getCollection(OperationContext* opCtx, } std::vector<CollectionType> ShardingCatalogClientMock::getCollections( - OperationContext* opCtx, StringData dbName, repl::ReadConcernLevel readConcernLevel) { + OperationContext* opCtx, + StringData dbName, + repl::ReadConcernLevel readConcernLevel, + const BSONObj& sort) { uasserted(ErrorCodes::InternalError, "Method not implemented"); } diff --git a/src/mongo/s/catalog/sharding_catalog_client_mock.h b/src/mongo/s/catalog/sharding_catalog_client_mock.h index 70ba2f74a88..888d00da2c5 100644 --- a/src/mongo/s/catalog/sharding_catalog_client_mock.h +++ b/src/mongo/s/catalog/sharding_catalog_client_mock.h @@ -58,7 +58,8 @@ public: std::vector<CollectionType> getCollections(OperationContext* opCtx, StringData db, - repl::ReadConcernLevel readConcernLevel) override; + repl::ReadConcernLevel readConcernLevel, + const BSONObj& sort) override; std::vector<NamespaceString> getAllShardedCollectionsForDb( OperationContext* opCtx, StringData dbName, repl::ReadConcernLevel readConcern) override; |