diff options
author | Maria van Keulen <maria@mongodb.com> | 2018-07-27 17:09:24 -0400 |
---|---|---|
committer | Maria van Keulen <maria@mongodb.com> | 2018-08-07 14:26:55 -0400 |
commit | 88a8b7b31ca41eca88e782d84e496911c93cc0ae (patch) | |
tree | f60e0bee8e351180ad2c256c3c8946ec35fadeb6 /src/mongo/s | |
parent | 4c16f0f336f4db77034e8aa594bbd4a5bac3f40c (diff) | |
download | mongo-88a8b7b31ca41eca88e782d84e496911c93cc0ae.tar.gz |
SERVER-36257 Remove copyDB and clone commands
Diffstat (limited to 'src/mongo/s')
-rw-r--r-- | src/mongo/s/commands/commands_public.cpp | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/src/mongo/s/commands/commands_public.cpp b/src/mongo/s/commands/commands_public.cpp index 3b92e72caed..96c448988aa 100644 --- a/src/mongo/s/commands/commands_public.cpp +++ b/src/mongo/s/commands/commands_public.cpp @@ -37,7 +37,6 @@ #include "mongo/db/auth/authorization_session.h" #include "mongo/db/auth/privilege.h" #include "mongo/db/commands.h" -#include "mongo/db/commands/copydb.h" #include "mongo/db/commands/rename_collection.h" #include "mongo/executor/task_executor_pool.h" #include "mongo/rpc/get_status_from_command_result.h" @@ -232,107 +231,6 @@ public: } renameCollectionCmd; -class CopyDBCmd : public BasicCommand { -public: - CopyDBCmd() : BasicCommand("copydb") {} - - AllowedOnSecondary secondaryAllowed(ServiceContext*) const override { - return AllowedOnSecondary::kNever; - } - - bool adminOnly() const override { - return true; - } - - Status checkAuthForCommand(Client* client, - const std::string& dbname, - const BSONObj& cmdObj) const override { - return copydb::checkAuthForCopydbCommand(client, dbname, cmdObj); - } - - bool supportsWriteConcern(const BSONObj& cmd) const override { - return true; - } - - bool run(OperationContext* opCtx, - const std::string& dbName, - const BSONObj& cmdObj, - BSONObjBuilder& result) override { - const auto todbElt = cmdObj["todb"]; - uassert(ErrorCodes::InvalidNamespace, - "'todb' must be of type String", - todbElt.type() == BSONType::String); - const std::string todb = todbElt.str(); - uassert(ErrorCodes::InvalidNamespace, - "Invalid todb argument", - NamespaceString::validDBName(todb, NamespaceString::DollarInDbNameBehavior::Allow)); - - auto toDbInfo = uassertStatusOK(createShardDatabase(opCtx, todb)); - uassert(ErrorCodes::IllegalOperation, - "Cannot copy to a sharded database", - !toDbInfo.shardingEnabled()); - - const auto copyDbCmdObj = cmdObj["fromhost"] ? cmdObj : [&] { - const auto fromDbElt = cmdObj["fromdb"]; - uassert(ErrorCodes::InvalidNamespace, - "'fromdb' must be of type String", - fromDbElt.type() == BSONType::String); - const std::string fromdb = fromDbElt.str(); - uassert(ErrorCodes::InvalidNamespace, - "invalid fromdb argument", - NamespaceString::validDBName(fromdb, - NamespaceString::DollarInDbNameBehavior::Allow)); - - auto fromDbInfo = uassertStatusOK(createShardDatabase(opCtx, fromdb)); - uassert(ErrorCodes::IllegalOperation, - "Cannot copy from a sharded database", - !fromDbInfo.shardingEnabled()); - - // If the source and destination are the same, there is no need to attach the 'fromhost' - // field since the copy is entirely local to the node - if (fromDbInfo.primaryId() == toDbInfo.primaryId()) { - return cmdObj; - } - - BSONObjBuilder copyDbCmdObjBuilder; - - // Copy everything but the "fromhost" parameter - BSONForEach(e, cmdObj) { - if (strcmp(e.fieldName(), "fromhost")) { - copyDbCmdObjBuilder.append(e); - } - } - - // Append "fromhost" as the database's primary - { - const auto shard = uassertStatusOK( - Grid::get(opCtx)->shardRegistry()->getShard(opCtx, fromDbInfo.primaryId())); - copyDbCmdObjBuilder.append("fromhost", shard->getConnString().toString()); - } - - return copyDbCmdObjBuilder.obj(); - }(); - - // copyDb creates multiple collections and should handle collection creation differently - auto response = executeCommandAgainstDatabasePrimary( - opCtx, - NamespaceString::kAdminDb, - toDbInfo, - appendAllowImplicitCreate( - CommandHelpers::filterCommandRequestForPassthrough(copyDbCmdObj), true), - ReadPreferenceSetting(ReadPreference::PrimaryOnly), - Shard::RetryPolicy::kNoRetry); - - const auto cmdResponse = uassertStatusOK(std::move(response.swResponse)); - const auto status = getStatusFromCommandResult(cmdResponse.data); - - result.appendElementsUnique( - CommandHelpers::filterCommandReplyForPassthrough(cmdResponse.data)); - return status.isOK(); - } - -} clusterCopyDBCmd; - class ConvertToCappedCmd : public BasicCommand { public: ConvertToCappedCmd() : BasicCommand("convertToCapped") {} |