2010-04-14 17:30:23 -04:00
|
|
|
/**
|
|
|
|
|
* Copyright (C) 2008 10gen 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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2010-04-27 15:27:52 -04:00
|
|
|
#include "pch.h"
|
2010-04-14 17:30:23 -04:00
|
|
|
#include "../cmdline.h"
|
|
|
|
|
#include "../commands.h"
|
2010-05-08 14:12:24 -04:00
|
|
|
#include "health.h"
|
2010-04-23 17:35:05 -04:00
|
|
|
#include "replset.h"
|
|
|
|
|
#include "rs_config.h"
|
2010-04-14 17:30:23 -04:00
|
|
|
|
|
|
|
|
namespace mongo {
|
|
|
|
|
|
2010-04-18 12:30:40 -04:00
|
|
|
/* commands in other files:
|
|
|
|
|
replSetHeartbeat - health.cpp
|
2010-05-08 14:12:24 -04:00
|
|
|
replSetInitiate - rs_mod.cpp
|
2010-04-22 18:43:37 -04:00
|
|
|
*/
|
2010-04-18 12:30:40 -04:00
|
|
|
|
2010-04-14 17:30:23 -04:00
|
|
|
class CmdReplSetGetStatus : public Command {
|
|
|
|
|
public:
|
2010-04-23 15:50:49 -04:00
|
|
|
virtual bool slaveOk() const { return true; }
|
2010-04-23 16:41:56 -04:00
|
|
|
virtual bool adminOnly() const { return true; }
|
2010-04-22 16:17:18 -04:00
|
|
|
virtual bool logTheOp() { return false; }
|
2010-04-23 15:50:49 -04:00
|
|
|
virtual LockType locktype() const { return NONE; }
|
|
|
|
|
virtual void help( stringstream &help ) const {
|
|
|
|
|
help << "Report status of a replica set from the POV of this server\n";
|
|
|
|
|
help << "{ replSetGetStatus : 1 }";
|
2010-04-25 16:13:21 -04:00
|
|
|
help << "\nhttp://www.mongodb.org/display/DOCS/Replica+Set+Commands";
|
2010-04-23 15:50:49 -04:00
|
|
|
}
|
|
|
|
|
|
2010-04-19 21:05:46 -04:00
|
|
|
CmdReplSetGetStatus() : Command("replSetGetStatus", true) { }
|
2010-05-03 16:25:34 -04:00
|
|
|
virtual bool run(const string& , BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
|
2010-04-21 21:19:37 -04:00
|
|
|
if( !replSet ) {
|
|
|
|
|
errmsg = "not running with --replSet";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-04-20 12:29:00 -04:00
|
|
|
if( theReplSet == 0 ) {
|
2010-04-23 17:35:05 -04:00
|
|
|
result.append("startupStatus", ReplSet::startupStatus);
|
2010-04-21 17:40:24 -04:00
|
|
|
errmsg = ReplSet::startupStatusMsg.empty() ?
|
2010-04-21 21:19:37 -04:00
|
|
|
errmsg = "replset unknown error 1" : ReplSet::startupStatusMsg;
|
2010-04-20 12:29:00 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
theReplSet->summarizeStatus(result);
|
|
|
|
|
|
2010-04-14 17:30:23 -04:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
} cmdReplSetGetStatus;
|
|
|
|
|
|
2010-04-25 16:13:21 -04:00
|
|
|
class CmdReplSetFreeze : public Command {
|
|
|
|
|
public:
|
|
|
|
|
virtual bool slaveOk() const { return true; }
|
|
|
|
|
virtual bool adminOnly() const { return true; }
|
|
|
|
|
virtual bool logTheOp() { return false; }
|
|
|
|
|
virtual LockType locktype() const { return NONE; }
|
|
|
|
|
virtual void help( stringstream &help ) const {
|
|
|
|
|
help << "Enable / disable failover for the set - locks current primary as primary even if issues occur.\nFor use during system maintenance.\n";
|
|
|
|
|
help << "{ replSetFreeze : <bool> }";
|
|
|
|
|
help << "\nhttp://www.mongodb.org/display/DOCS/Replica+Set+Commands";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CmdReplSetFreeze() : Command("replSetFreeze", true) { }
|
2010-05-03 16:25:34 -04:00
|
|
|
virtual bool run(const string& , BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
|
2010-04-25 16:13:21 -04:00
|
|
|
if( !replSet ) {
|
|
|
|
|
errmsg = "not running with --replSet";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if( theReplSet == 0 ) {
|
|
|
|
|
result.append("startupStatus", ReplSet::startupStatus);
|
|
|
|
|
errmsg = ReplSet::startupStatusMsg.empty() ?
|
|
|
|
|
errmsg = "replset unknown error 1" : ReplSet::startupStatusMsg;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
errmsg = "not yet implemented"; /*TODO*/
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} cmdReplSetFreeze;
|
|
|
|
|
|
2010-04-14 17:30:23 -04:00
|
|
|
}
|