summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Lerner <alerner@10gen.com>2010-07-16 15:06:51 -0400
committerAlberto Lerner <alerner@10gen.com>2010-07-16 15:06:51 -0400
commit788f3fe47215c423f275ec539e4eaefdb7546a92 (patch)
tree84e9e8aca9d7d8b68f619f0e9a93c7feffa5992d
parent38eb41bf4a7ab62ac988254607b356e668d92332 (diff)
parent90a40275dbc6792029ba2d10fff02f6cfcdfbfdf (diff)
downloadmongo-788f3fe47215c423f275ec539e4eaefdb7546a92.tar.gz
Merge branch 'master' of github.com:mongodb/mongo
-rw-r--r--db/repl/heartbeat.cpp3
-rw-r--r--db/repl/rs.cpp3
-rw-r--r--db/repl/rs.h15
-rw-r--r--db/repl/rs_initiate.cpp2
-rw-r--r--db/repl/rs_sync.cpp3
-rw-r--r--shell/utils.js2
6 files changed, 23 insertions, 5 deletions
diff --git a/db/repl/heartbeat.cpp b/db/repl/heartbeat.cpp
index 1b8381d5c7e..213c6cd00a9 100644
--- a/db/repl/heartbeat.cpp
+++ b/db/repl/heartbeat.cpp
@@ -76,6 +76,7 @@ namespace mongo {
}
result.append("set", theReplSet->name());
result.append("state", theReplSet->state());
+ result.append("hbmsg", theReplSet->hbmsg());
result.appendDate("opTime", theReplSet->lastOpTimeWritten.asDate());
int v = theReplSet->config().version;
result.append("v", v);
@@ -130,7 +131,7 @@ namespace mongo {
mem.upSince = mem.lastHeartbeat;
}
mem.health = 1.0;
- mem.lastHeartbeatMsg = "";
+ mem.lastHeartbeatMsg = info["hbmsg"].String();
if( info.hasElement("opTime") )
mem.opTime = info["opTime"].Date();
diff --git a/db/repl/rs.cpp b/db/repl/rs.cpp
index cd9a09d6a5a..ae32885fbd6 100644
--- a/db/repl/rs.cpp
+++ b/db/repl/rs.cpp
@@ -151,6 +151,8 @@ namespace mongo {
_self(0),
mgr( new Manager(this) )
{
+ memset(_hbmsg, 0, sizeof(_hbmsg));
+ *_hbmsg = '.'; // temp...just to see
h = 0;
_myState = STARTUP;
_currentPrimary = 0;
@@ -355,6 +357,7 @@ namespace mongo {
{
//lock l(this);
_myState = FATAL;
+ sethbmsg("fatal error");
log() << "replSet error fatal error, stopping replication" << rsLog;
}
diff --git a/db/repl/rs.h b/db/repl/rs.h
index 0f023fbd988..b4c105af413 100644
--- a/db/repl/rs.h
+++ b/db/repl/rs.h
@@ -182,6 +182,14 @@ namespace mongo {
void loadLastOpTimeWritten();
protected:
+ // "heartbeat message"
+ // sent in requestHeartbeat respond in field "hbm"
+ char _hbmsg[256];
+ void sethbmsg(string s) {
+ assert(s.size() < sizeof(_hbmsg));
+ strcpy(_hbmsg, s.c_str());
+ }
+
bool initFromConfig(ReplSetConfig& c); // true if ok; throws if config really bad; false if config doesn't include self
void _fillIsMaster(BSONObjBuilder&);
void _fillIsMasterHost(const Member*, vector<string>&, vector<string>&, vector<string>&);
@@ -199,7 +207,7 @@ namespace mongo {
throws exception if a problem initializing. */
ReplSetImpl(string cfgString);
- /* call after constructing to start - returns fairly quickly after launching its threads */
+ /* call afer constructing to start - returns fairly quickly after launching its threads */
void _go();
private:
@@ -245,7 +253,8 @@ namespace mongo {
class ReplSet : public ReplSetImpl {
public:
- ReplSet(string cfgString) : ReplSetImpl(cfgString) { }
+ ReplSet(string cfgString) : ReplSetImpl(cfgString) {
+ }
/* call after constructing to start - returns fairly quickly after la[unching its threads */
void go() { _go(); }
@@ -267,6 +276,8 @@ namespace mongo {
bool lockedByMe() { return RSBase::lockedByMe(); }
+ // heartbeat msg to send to others; descriptive diagnostic info
+ string hbmsg() const { return _hbmsg; }
};
/** base class for repl set commands. checks basic things such as in rs mode before the command
diff --git a/db/repl/rs_initiate.cpp b/db/repl/rs_initiate.cpp
index 4968d550df4..e6a0e3bbdb9 100644
--- a/db/repl/rs_initiate.cpp
+++ b/db/repl/rs_initiate.cpp
@@ -104,7 +104,7 @@ namespace mongo {
}
if( theReplSet ) {
errmsg = "already initialized";
- result.append("info", "try querying " + rsConfigNs + "");
+ result.append("info", "try querying " + rsConfigNs + " to see current configuration");
return false;
}
diff --git a/db/repl/rs_sync.cpp b/db/repl/rs_sync.cpp
index 83e2884212f..763907b7ce5 100644
--- a/db/repl/rs_sync.cpp
+++ b/db/repl/rs_sync.cpp
@@ -25,8 +25,9 @@ namespace mongo {
void ReplSetImpl::syncDoInitialSync() {
log() << "replSet syncDoInitialSync" << rsLog;
+ sethbmsg("initial sync drop all databases");
dropAllDatabasesExceptLocal();
-
+ sethbmsg("initial sync - not yet implemented");
}
void syncThread() {
diff --git a/shell/utils.js b/shell/utils.js
index 33c3887e28b..67a023236d9 100644
--- a/shell/utils.js
+++ b/shell/utils.js
@@ -1054,6 +1054,8 @@ rs.help = function () {
print("\trs.conf() return configuration from local.system.replset");
print();
print("\tdb.isMaster() check who is primary");
+ print();
+ print("\tsee also http://<host>:28017/_replSet for additional diagnostic info");
}
rs.status = function () { return db._adminCommand("replSetGetStatus"); }
rs.initiate = function (c) { return db._adminCommand({ replSetInitiate: c }); }