summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/database_sharding_state.h
diff options
context:
space:
mode:
authorBlake Oler <blake.oler@mongodb.com>2018-03-13 16:09:21 -0400
committerBlake Oler <blake.oler@mongodb.com>2018-03-19 16:53:06 -0400
commit30314ef38819701600a5617390fe3721e2b9dbdf (patch)
tree5a3947ec5451f6d5a0852a906a479b6a00f0cc3a /src/mongo/db/s/database_sharding_state.h
parent33da87d9b0f5dd6f1b2c8d454b22345a1d0f1d4e (diff)
downloadmongo-30314ef38819701600a5617390fe3721e2b9dbdf.tar.gz
SERVER-33206 Create MovePrimarySourceManager and add clone command
Diffstat (limited to 'src/mongo/db/s/database_sharding_state.h')
-rw-r--r--src/mongo/db/s/database_sharding_state.h27
1 files changed, 27 insertions, 0 deletions
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<DatabaseVersion> _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