summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/tenant_migration_donor_cmds.cpp
diff options
context:
space:
mode:
authorCheahuychou Mao <cheahuychou.mao@mongodb.com>2020-08-10 14:06:27 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-08-24 17:27:52 +0000
commit0cbcb7f3825461348db9b9fb4bc951baf1f0c832 (patch)
tree6982532a275cb1b78ed9477a84032d848bf86e7c /src/mongo/db/commands/tenant_migration_donor_cmds.cpp
parent6ec7b6ce8a2dfb46f5e76c7d031e8dd81e5375fd (diff)
downloadmongo-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.cpp27
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: