diff options
author | Andy Schwerin <schwerin@mongodb.com> | 2018-04-23 16:57:11 -0400 |
---|---|---|
committer | Andy Schwerin <schwerin@mongodb.com> | 2018-04-23 16:57:11 -0400 |
commit | 046740799031ca275dc3e9a5e25c4d1581ab88fb (patch) | |
tree | 573c78961c137a2ac180d74b032285e11cf5b3b8 /src/mongo/db/s/collection_sharding_state.h | |
parent | 62119ef6bd1282289a0f27af792df2aca828c1b9 (diff) | |
download | mongo-046740799031ca275dc3e9a5e25c4d1581ab88fb.tar.gz |
SERVER-29908 Move OpObserver and MigrationSourceManager logic out of CollectionShardingState.
Makes MigrationSourceManager a decoration on CollectionShardingState,
not a member and moves the op observer behavior from
CollectionShardingState to free functions in shard_server_op_observer.h/cpp.
Diffstat (limited to 'src/mongo/db/s/collection_sharding_state.h')
-rw-r--r-- | src/mongo/db/s/collection_sharding_state.h | 63 |
1 files changed, 2 insertions, 61 deletions
diff --git a/src/mongo/db/s/collection_sharding_state.h b/src/mongo/db/s/collection_sharding_state.h index 6aa2463dc9d..2df1699c450 100644 --- a/src/mongo/db/s/collection_sharding_state.h +++ b/src/mongo/db/s/collection_sharding_state.h @@ -36,10 +36,10 @@ #include "mongo/db/namespace_string.h" #include "mongo/db/s/metadata_manager.h" #include "mongo/db/s/sharding_migration_critical_section.h" +#include "mongo/util/decorable.h" namespace mongo { -class MigrationSourceManager; class OperationContext; /** @@ -50,7 +50,7 @@ class OperationContext; * Synchronization rules: In order to look-up this object in the instance's sharding map, one must * have some lock on the respective collection. */ -class CollectionShardingState { +class CollectionShardingState : public Decorable<CollectionShardingState> { MONGO_DISALLOW_COPYING(CollectionShardingState); public: @@ -60,22 +60,6 @@ public: * Instantiates a new per-collection sharding state as unsharded. */ CollectionShardingState(ServiceContext* sc, NamespaceString nss); - ~CollectionShardingState(); - - /** - * Details of documents being removed from a sharded collection. - */ - struct DeleteState { - // Contains the fields of the document that are in the collection's shard key, and "_id". - BSONObj documentKey; - - // True if the document being deleted belongs to a chunk which, while still in the shard, - // is being migrated out. (Not to be confused with "fromMigrate", which tags operations - // that are steps in performing the migration.) - bool isMigrating; - }; - - DeleteState makeDeleteState(OperationContext* opCtx, BSONObj const& doc); /** * Obtains the sharding state for the specified collection. If it does not exist, it will be @@ -168,24 +152,6 @@ public: } /** - * Attaches a migration source manager to this collection's sharding state. Must be called with - * collection X lock. May not be called if there is a migration source manager already - * installed. Must be followed by a call to clearMigrationSourceManager. - */ - void setMigrationSourceManager(OperationContext* opCtx, MigrationSourceManager* sourceMgr); - - auto getMigrationSourceManager() const { - return _sourceMgr; - } - - /** - * Removes a migration source manager from this collection's sharding state. Must be called with - * collection X lock. May not be called if there isn't a migration source manager installed - * already through a previous call to setMigrationSourceManager. - */ - void clearMigrationSourceManager(OperationContext* opCtx); - - /** * Checks whether the shard version in the context is compatible with the shard version of the * collection locally and if not throws StaleConfigException populated with the expected and * actual versions. @@ -226,24 +192,6 @@ public: */ boost::optional<ChunkRange> getNextOrphanRange(BSONObj const& startingFrom); - /** - * Replication oplog OpObserver hooks. Informs the sharding system of changes that may be - * relevant to ongoing operations. - * - * The global exclusive lock is expected to be held by the caller of any of these functions. - */ - void onInsertOp(OperationContext* opCtx, - const BSONObj& insertedDoc, - const repl::OpTime& opTime); - void onUpdateOp(OperationContext* opCtx, - const BSONObj& updatedDoc, - const repl::OpTime& opTime, - const repl::OpTime& prePostImageOpTime); - void onDeleteOp(OperationContext* opCtx, - const DeleteState& deleteState, - const repl::OpTime& opTime, - const repl::OpTime& preImageOpTime); - private: /** * Checks whether the shard version of the operation matches that of the collection. @@ -271,13 +219,6 @@ private: ShardingMigrationCriticalSection _critSec; - // If this collection is serving as a source shard for chunk migration, this value will be - // non-null. To write this value there needs to be X-lock on the collection in order to - // synchronize with other callers, which read it. - // - // NOTE: The value is not owned by this class. - MigrationSourceManager* _sourceMgr{nullptr}; - // for access to _metadataManager friend auto CollectionRangeDeleter::cleanUpNextRange(OperationContext*, NamespaceString const&, |