From 30314ef38819701600a5617390fe3721e2b9dbdf Mon Sep 17 00:00:00 2001 From: Blake Oler Date: Tue, 13 Mar 2018 16:09:21 -0400 Subject: SERVER-33206 Create MovePrimarySourceManager and add clone command --- src/mongo/db/s/database_sharding_state.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/mongo/db/s/database_sharding_state.h') diff --git a/src/mongo/db/s/database_sharding_state.h b/src/mongo/db/s/database_sharding_state.h index d5e09aa55f0..451396471c3 100644 --- a/src/mongo/db/s/database_sharding_state.h +++ b/src/mongo/db/s/database_sharding_state.h @@ -35,6 +35,7 @@ namespace mongo { +class MovePrimarySourceManager; class OperationContext; /** @@ -76,6 +77,25 @@ public: */ void checkDbVersion(OperationContext* opCtx) const; + /** + * Returns the active movePrimary source manager, if one is available. + */ + MovePrimarySourceManager* getMovePrimarySourceManager(); + + /** + * Attaches a movePrimary source manager to this database's sharding state. Must be called with + * the database lock in X mode. May not be called if there is a movePrimary source manager + * already installed. Must be followed by a call to clearMovePrimarySourceManager. + */ + void setMovePrimarySourceManager(OperationContext* opCtx, MovePrimarySourceManager* sourceMgr); + + /** + * Removes a movePrimary source manager from this database's sharding state. Must be called with + * with the database lock in X mode. May not be called if there isn't a movePrimary source + * manager installed already through a previous call to setMovePrimarySourceManager. + */ + void clearMovePrimarySourceManager(OperationContext* opCtx); + private: // Modifying the state below requires holding the DBLock in X mode; holding the DBLock in any // mode is acceptable for reading it. (Note: accessing this class at all requires holding the @@ -86,6 +106,13 @@ private: // This shard server's cached dbVersion. If boost::none, indicates this shard server does not // know the dbVersion. boost::optional _dbVersion = boost::none; + + // If this database is serving as a source shard for a movePrimary, the source manager will be + // non-null. To write this value, there needs to be X-lock on the database in order to + // synchronize with other callers which will read the source manager. + // + // NOTE: The source manager is not owned by this class. + MovePrimarySourceManager* _sourceMgr{nullptr}; }; } // namespace mongo -- cgit v1.2.1