summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/s/SConscript1
-rw-r--r--src/mongo/db/s/config/configsvr_drop_collection_command.cpp90
2 files changed, 91 insertions, 0 deletions
diff --git a/src/mongo/db/s/SConscript b/src/mongo/db/s/SConscript
index 6ae29f02a03..b05686b906e 100644
--- a/src/mongo/db/s/SConscript
+++ b/src/mongo/db/s/SConscript
@@ -169,6 +169,7 @@ env.Library(
'config/configsvr_commit_chunk_migration_command.cpp',
'config/configsvr_control_balancer_command.cpp',
'config/configsvr_create_database_command.cpp',
+ 'config/configsvr_drop_collection_command.cpp',
'config/configsvr_enable_sharding_command.cpp',
'config/configsvr_merge_chunk_command.cpp',
'config/configsvr_move_chunk_command.cpp',
diff --git a/src/mongo/db/s/config/configsvr_drop_collection_command.cpp b/src/mongo/db/s/config/configsvr_drop_collection_command.cpp
new file mode 100644
index 00000000000..a611c469f5a
--- /dev/null
+++ b/src/mongo/db/s/config/configsvr_drop_collection_command.cpp
@@ -0,0 +1,90 @@
+/**
+ * Copyright (C) 2017 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/db/auth/authorization_session.h"
+#include "mongo/db/client.h"
+#include "mongo/db/commands.h"
+#include "mongo/db/operation_context.h"
+
+namespace mongo {
+
+namespace {
+
+/**
+ * Internal sharding command run on config servers to drop a collection from a database.
+ */
+class ConfigSvrDropCollectionCommand : public BasicCommand {
+public:
+ ConfigSvrDropCollectionCommand() : BasicCommand("_configsvrDropCollection") {}
+
+ bool slaveOk() const override {
+ return false;
+ }
+
+ bool adminOnly() const override {
+ return true;
+ }
+
+ bool supportsWriteConcern(const BSONObj& cmd) const override {
+ return true;
+ }
+
+ void help(std::stringstream& help) const override {
+ help << "Internal command, which is exported by the sharding config server. Do not call "
+ "directly. Drops a collection from a database.";
+ }
+
+ Status checkAuthForCommand(Client* client,
+ const std::string& dbname,
+ const BSONObj& cmdObj) override {
+ if (!AuthorizationSession::get(client)->isAuthorizedForActionsOnResource(
+ ResourcePattern::forClusterResource(), ActionType::internal)) {
+ return Status(ErrorCodes::Unauthorized, "Unauthorized");
+ }
+ return Status::OK();
+ }
+
+ bool run(OperationContext* opCtx,
+ const std::string& dbname,
+ const BSONObj& cmdObj,
+ BSONObjBuilder& result) {
+ // TODO SERVER-30504: move logic over from DropCmd
+ return true;
+ }
+
+private:
+ static void _dropUnshardedCollectionFromShard(OperationContext* opCtx,
+ const ShardId& shardId,
+ const NamespaceString& nss,
+ BSONObjBuilder* result){
+ // TODO SERVER-30504: move logic over from DropCmd
+ };
+} configsvrDropCollectionCmd;
+
+} // namespace
+} // namespace mongo