diff options
author | Eric Milkie <milkie@10gen.com> | 2016-04-28 10:39:38 -0400 |
---|---|---|
committer | Eric Milkie <milkie@10gen.com> | 2016-05-02 10:50:13 -0400 |
commit | c52c530428fbbe0cae1293ad6605c3ab7be2a281 (patch) | |
tree | b4e007e87a4ee76b645bc27ed20924c6ddad7504 /src/mongo/db/cloner.h | |
parent | 1c5be329f5e3903d5cd4e9d106022733507b5e3f (diff) | |
download | mongo-c52c530428fbbe0cae1293ad6605c3ab7be2a281.tar.gz |
SERVER-23919 gather all collection names at the start of initial sync
Diffstat (limited to 'src/mongo/db/cloner.h')
-rw-r--r-- | src/mongo/db/cloner.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/mongo/db/cloner.h b/src/mongo/db/cloner.h index 8a5cb691375..7b091e4f29b 100644 --- a/src/mongo/db/cloner.h +++ b/src/mongo/db/cloner.h @@ -30,6 +30,9 @@ #pragma once +#include <vector> +#include <string> + #include "mongo/base/disallow_copying.h" #include "mongo/client/dbclientinterface.h" #include "mongo/s/catalog/catalog_manager.h" @@ -54,12 +57,18 @@ public: /** * Copies an entire database from the specified host. + * clonedColls: when not-null, the function will return with this populated with a list of + * the collections that were cloned. This is for the user-facing clone command. + * collectionsToClone: When opts.createCollections is false, this list reflects the collections + * that are cloned. When opts.createCollections is true, this parameter is + * ignored and the collection list is fetched from the remote via _conn. */ Status copyDb(OperationContext* txn, const std::string& toDBName, const std::string& masterHost, const CloneOptions& opts, - std::set<std::string>* clonedColls); + std::set<std::string>* clonedColls, + std::vector<BSONObj> collectionsToClone = std::vector<BSONObj>()); bool copyCollection(OperationContext* txn, const std::string& ns, @@ -67,6 +76,17 @@ public: std::string& errmsg, bool copyIndexes); + // Filters a database's collection list and removes collections that should not be cloned. + // CloneOptions should be populated with a fromDB and a list of collections to ignore, which + // will be filtered out. + StatusWith<std::vector<BSONObj>> filterCollectionsForClone( + const CloneOptions& opts, const std::list<BSONObj>& initialCollections); + + // Executes 'createCollection' for each collection specified in 'collections', in 'dbName'. + Status createCollectionsForDb(OperationContext* txn, + const std::vector<BSONObj>& collections, + const std::string& dbName); + private: void copy(OperationContext* txn, const std::string& toDBName, @@ -99,6 +119,8 @@ private: * holding a distributed lock (such as movePrimary). Indicates that we need to * be periodically checking to see if the catalog manager has swapped and fail * if it has so that we don't block the mongos that initiated the command. + * createCollections - When 'true', will fetch a list of collections from the remote and create + * them. When 'false', assumes collections have already been created ahead of time. */ struct CloneOptions { std::string fromDB; @@ -111,6 +133,7 @@ struct CloneOptions { bool syncData = true; bool syncIndexes = true; bool checkForCatalogChange = false; + bool createCollections = true; }; } // namespace mongo |