summaryrefslogtreecommitdiff
path: root/src/mongo/s/commands/cluster_is_master_cmd.cpp
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2015-03-11 10:38:01 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2015-03-11 16:30:45 -0400
commit73986ce87913a552858cfd4c187a0f1059324a03 (patch)
tree5e8437e401115bb043db7098c7e63bec5a290aea /src/mongo/s/commands/cluster_is_master_cmd.cpp
parent5fd3dfce18655932165ebadef0bbe5ed58f678de (diff)
downloadmongo-73986ce87913a552858cfd4c187a0f1059324a03.tar.gz
SERVER-17496 Move all admin commands to separate files
Diffstat (limited to 'src/mongo/s/commands/cluster_is_master_cmd.cpp')
-rw-r--r--src/mongo/s/commands/cluster_is_master_cmd.cpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/src/mongo/s/commands/cluster_is_master_cmd.cpp b/src/mongo/s/commands/cluster_is_master_cmd.cpp
new file mode 100644
index 00000000000..6bc41b14cc3
--- /dev/null
+++ b/src/mongo/s/commands/cluster_is_master_cmd.cpp
@@ -0,0 +1,87 @@
+/**
+ * Copyright (C) 2015 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/platform/basic.h"
+
+#include "mongo/db/commands.h"
+#include "mongo/db/wire_version.h"
+#include "mongo/s/write_ops/batched_command_request.h"
+
+namespace mongo {
+namespace {
+
+ class CmdIsMaster : public Command {
+ public:
+ CmdIsMaster() : Command("isMaster", false, "ismaster") { }
+
+ virtual bool isWriteCommandForConfigServer() const {
+ return false;
+ }
+
+ virtual bool slaveOk() const {
+ return true;
+ }
+
+ virtual void help(std::stringstream& help) const {
+ help << "test if this is master half of a replica pair";
+ }
+
+ virtual void addRequiredPrivileges(const std::string& dbname,
+ const BSONObj& cmdObj,
+ std::vector<Privilege>* out) {
+
+ // No auth required
+ }
+
+ virtual bool run(OperationContext* txn,
+ const std::string& dbname,
+ BSONObj& cmdObj,
+ int options,
+ std::string& errmsg,
+ BSONObjBuilder& result,
+ bool fromRepl) {
+
+ result.appendBool("ismaster", true);
+ result.append("msg", "isdbgrid");
+ result.appendNumber("maxBsonObjectSize", BSONObjMaxUserSize);
+ result.appendNumber("maxMessageSizeBytes", MaxMessageSizeBytes);
+ result.appendNumber("maxWriteBatchSize", BatchedCommandRequest::kMaxWriteBatchSize);
+ result.appendDate("localTime", jsTime());
+
+ // Mongos tries to keep exactly the same version range of the server for which
+ // it is compiled.
+ result.append("maxWireVersion", maxWireVersion);
+ result.append("minWireVersion", minWireVersion);
+
+ return true;
+ }
+
+ } isMaster;
+
+} // namespace
+} // namespace mongo