diff options
author | Randolph Tan <randolph@10gen.com> | 2017-09-19 14:44:36 -0400 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2017-09-26 19:11:04 -0400 |
commit | 85d9721c00d7020af78fe60453f8362380fe697d (patch) | |
tree | 197240934bc6e849964449587234b526916e512d /src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp | |
parent | 457ecaf9ca73456df43e442ddd758b9067a6a002 (diff) | |
download | mongo-85d9721c00d7020af78fe60453f8362380fe697d.tar.gz |
SERVER-30894 Implement command for transferring session information during migration
Diffstat (limited to 'src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp')
-rw-r--r-- | src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp b/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp index 9e3e83774ee..d42c6bdaa99 100644 --- a/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp +++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp @@ -216,5 +216,57 @@ public: } transferModsCommand; +/** + * Command for extracting the oplog entries that needs to be migrated for the given migration + * session id. + * Note: this command is not stateless. Calling this command has a side-effect of gradually + * depleting the buffer that contains the oplog entries to be transfered. + */ +class MigrateSessionCommand : public BasicCommand { +public: + MigrateSessionCommand() : BasicCommand("_getNextSessionMods") {} + + void help(std::stringstream& h) const { + h << "internal"; + } + + virtual bool supportsWriteConcern(const BSONObj& cmd) const override { + return false; + } + + virtual bool slaveOk() const { + return false; + } + + virtual bool adminOnly() const { + return true; + } + + virtual void addRequiredPrivileges(const std::string& dbname, + const BSONObj& cmdObj, + std::vector<Privilege>* out) { + ActionSet actions; + actions.addAction(ActionType::internal); + out->push_back(Privilege(ResourcePattern::forClusterResource(), actions)); + } + + bool run(OperationContext* opCtx, + const std::string&, + const BSONObj& cmdObj, + BSONObjBuilder& result) { + const MigrationSessionId migrationSessionId( + uassertStatusOK(MigrationSessionId::extractFromBSON(cmdObj))); + + BSONArrayBuilder arrBuilder; + + AutoGetActiveCloner autoCloner(opCtx, migrationSessionId); + autoCloner.getCloner()->nextSessionMigrationBatch(opCtx, &arrBuilder); + + result.appendArray("oplog", arrBuilder.arr()); + return true; + } + +} migrateSessionCommand; + } // namespace } // namespace mongo |