0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
This commit is contained in:
dwight 2010-07-26 16:04:54 -04:00
parent 66caa37da3
commit f611c9e68d
3 changed files with 31 additions and 1 deletions

View File

@ -72,7 +72,7 @@ namespace mongo {
s << td( id() );
double h = hbinfo().health;
bool ok = h > 0;
s << td(h);
s << td(red(str::stream() << h,h == 0));
s << td(ago(hbinfo().upSince));
bool never = false;
{

View File

@ -35,12 +35,17 @@ namespace mongo {
using namespace bson;
extern bool replSetBlind;
/* { replSetHeartbeat : <setname> } */
class CmdReplSetHeartbeat : public ReplSetCommand {
public:
virtual bool adminOnly() const { return false; }
CmdReplSetHeartbeat() : ReplSetCommand("replSetHeartbeat") { }
virtual bool run(const string& , BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
if( replSetBlind )
return false;
/* we don't call ReplSetCommand::check() here because heartbeat
checks many things that are pre-initialization. */
if( !replSet ) {
@ -89,6 +94,11 @@ namespace mongo {
/* throws dbexception */
bool requestHeartbeat(string setName, string memberFullName, BSONObj& result, int myCfgVersion, int& theirCfgVersion, bool checkEmpty) {
if( replSetBlind ) {
//sleepmillis( rand() );
return false;
}
BSONObj cmd = BSON( "replSetHeartbeat" << setName << "v" << myCfgVersion << "pv" << 1 << "checkEmpty" << checkEmpty );
// we might be talking to ourself - generally not a great idea to do outbound waiting calls in a write lock

View File

@ -32,6 +32,26 @@ namespace mongo {
using namespace bson;
bool replSetBlind = false;
class CmdReplSetTest : public ReplSetCommand {
public:
virtual void help( stringstream &help ) const {
help << "Just for testing : do not use.\n";
}
CmdReplSetTest() : ReplSetCommand("replSetTest", true) { }
virtual bool run(const string& , BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
if( !check(errmsg, result) )
return false;
if( cmdObj.hasElement("blind") ) {
replSetBlind = cmdObj.getBoolField("blind");
log() << "replSet WARNING via command setting replSetBlind=" << replSetBlind << rsLog;
return true;
}
return false;
}
} cmdReplSetTest;
class CmdReplSetGetStatus : public ReplSetCommand {
public:
virtual void help( stringstream &help ) const {