diff options
author | Cheahuychou Mao <cheahuychou.mao@mongodb.com> | 2020-08-10 14:06:27 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-24 17:27:52 +0000 |
commit | 0cbcb7f3825461348db9b9fb4bc951baf1f0c832 (patch) | |
tree | 6982532a275cb1b78ed9477a84032d848bf86e7c /src/mongo/db/commands/tenant_migration_donor_cmds.cpp | |
parent | 6ec7b6ce8a2dfb46f5e76c7d031e8dd81e5375fd (diff) | |
download | mongo-0cbcb7f3825461348db9b9fb4bc951baf1f0c832.tar.gz |
SERVER-50066 Rehost tenant migration donor's logic on Primary-Only Service
Diffstat (limited to 'src/mongo/db/commands/tenant_migration_donor_cmds.cpp')
-rw-r--r-- | src/mongo/db/commands/tenant_migration_donor_cmds.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/mongo/db/commands/tenant_migration_donor_cmds.cpp b/src/mongo/db/commands/tenant_migration_donor_cmds.cpp index 16e773b2e0f..ec9c2a74946 100644 --- a/src/mongo/db/commands/tenant_migration_donor_cmds.cpp +++ b/src/mongo/db/commands/tenant_migration_donor_cmds.cpp @@ -29,6 +29,8 @@ #include "mongo/db/commands.h" #include "mongo/db/commands/tenant_migration_donor_cmds_gen.h" +#include "mongo/db/repl/primary_only_service.h" +#include "mongo/db/repl/tenant_migration_donor_service.h" #include "mongo/db/repl/tenant_migration_donor_util.h" namespace mongo { @@ -42,19 +44,28 @@ public: public: using InvocationBase::InvocationBase; + void typedRun(OperationContext* opCtx) { const RequestType& requestBody = request(); - const TenantMigrationDonorDocument donorStateDoc( - requestBody.getMigrationId(), - requestBody.getRecipientConnectionString().toString(), - requestBody.getDatabasePrefix().toString(), - TenantMigrationDonorStateEnum::kDataSync); - - tenant_migration_donor::startMigration(opCtx, donorStateDoc); + const auto donorStateDoc = + TenantMigrationDonorDocument(requestBody.getMigrationId(), + requestBody.getRecipientConnectionString().toString(), + requestBody.getReadPreference(), + requestBody.getDatabasePrefix().toString(), + TenantMigrationDonorStateEnum::kDataSync) + .toBSON(); + + auto donorService = + repl::PrimaryOnlyServiceRegistry::get(opCtx->getServiceContext()) + ->lookupServiceByName(TenantMigrationDonorService::kServiceName); + auto donor = + TenantMigrationDonorService::Instance::getOrCreate(donorService, donorStateDoc); + uassertStatusOK(donor->checkIfOptionsConflict(donorStateDoc)); + + donor->onCompletion().get(); } - void doCheckAuthorization(OperationContext* opCtx) const {} private: |