diff options
Diffstat (limited to 'src/mongo/db/s/refine_collection_shard_key_coordinator.h')
-rw-r--r-- | src/mongo/db/s/refine_collection_shard_key_coordinator.h | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/src/mongo/db/s/refine_collection_shard_key_coordinator.h b/src/mongo/db/s/refine_collection_shard_key_coordinator.h index c2e70a0d067..c461383e876 100644 --- a/src/mongo/db/s/refine_collection_shard_key_coordinator.h +++ b/src/mongo/db/s/refine_collection_shard_key_coordinator.h @@ -35,7 +35,9 @@ namespace mongo { -class RefineCollectionShardKeyCoordinator : public ShardingDDLCoordinator { +class RefineCollectionShardKeyCoordinator + : public RecoverableShardingDDLCoordinator<RefineCollectionShardKeyCoordinatorDocument, + RefineCollectionShardKeyCoordinatorPhaseEnum> { public: using StateDoc = RefineCollectionShardKeyCoordinatorDocument; using Phase = RefineCollectionShardKeyCoordinatorPhaseEnum; @@ -45,40 +47,16 @@ public: void checkIfOptionsConflict(const BSONObj& coorDoc) const override; - boost::optional<BSONObj> reportForCurrentOp( - MongoProcessInterface::CurrentOpConnectionsMode connMode, - MongoProcessInterface::CurrentOpSessionsMode sessionMode) noexcept override; + void appendCommandInfo(BSONObjBuilder* cmdInfoBuilder) const override; private: - ShardingDDLCoordinatorMetadata const& metadata() const override { - return _doc.getShardingDDLCoordinatorMetadata(); + StringData serializePhase(const Phase& phase) const override { + return RefineCollectionShardKeyCoordinatorPhase_serializer(phase); } ExecutorFuture<void> _runImpl(std::shared_ptr<executor::ScopedTaskExecutor> executor, const CancellationToken& token) noexcept override; - template <typename Func> - auto _executePhase(const Phase& newPhase, Func&& func) { - return [=] { - const auto& currPhase = _doc.getPhase(); - - if (currPhase > newPhase) { - // Do not execute this phase if we already reached a subsequent one. - return; - } - if (currPhase < newPhase) { - // Persist the new phase if this is the first time we are executing it. - _enterPhase(newPhase); - } - return func(); - }; - } - - void _enterPhase(Phase newPhase); - - mutable Mutex _docMutex = MONGO_MAKE_LATCH("RefineCollectionShardKeyCoordinator::_docMutex"); - RefineCollectionShardKeyCoordinatorDocument _doc; - const mongo::RefineCollectionShardKeyRequest _request; const KeyPattern _newShardKey; |