From cd89ae05d7fe9bcbbf44e919a55e7b60c1e476bc Mon Sep 17 00:00:00 2001 From: Kristina Date: Wed, 6 Apr 2011 12:41:48 -0400 Subject: [PATCH] add syncingTo field to rs status --- db/repl/health.cpp | 3 +++ db/repl/rs.cpp | 1 + db/repl/rs.h | 1 + db/repl/rs_initialsync.cpp | 2 ++ 4 files changed, 7 insertions(+) diff --git a/db/repl/health.cpp b/db/repl/health.cpp index add3f58885e..e12fab37e6b 100644 --- a/db/repl/health.cpp +++ b/db/repl/health.cpp @@ -417,6 +417,9 @@ namespace mongo { b.append("set", name()); b.appendTimeT("date", time(0)); b.append("myState", box.getState().s); + if (_currentSyncTarget) { + b.append("syncingTo", _currentSyncTarget->fullName()); + } b.append("members", v); if( replSetBlind ) b.append("blind",true); // to avoid confusion if set...normally never set except for testing. diff --git a/db/repl/rs.cpp b/db/repl/rs.cpp index 593bcb14d66..3863c324685 100644 --- a/db/repl/rs.cpp +++ b/db/repl/rs.cpp @@ -263,6 +263,7 @@ namespace mongo { } ReplSetImpl::ReplSetImpl(ReplSetCmdline& replSetCmdline) : elect(this), + _currentSyncTarget(0), _hbmsgTime(0), _self(0), mgr( new Manager(this) ) { diff --git a/db/repl/rs.h b/db/repl/rs.h index 05674857105..beffb941ff9 100644 --- a/db/repl/rs.h +++ b/db/repl/rs.h @@ -277,6 +277,7 @@ namespace mongo { * Find the closest member (using ping time) with a higher latest optime. */ const Member* getMemberToSyncTo(); + Member* _currentSyncTarget; protected: // "heartbeat message" // sent in requestHeartbeat respond in field "hbm" diff --git a/db/repl/rs_initialsync.cpp b/db/repl/rs_initialsync.cpp index c70920c00b7..98a195fcb70 100644 --- a/db/repl/rs_initialsync.cpp +++ b/db/repl/rs_initialsync.cpp @@ -97,10 +97,12 @@ namespace mongo { if (!closest) { sethbmsg("couldn't find a member to sync from"); + _currentSyncTarget = NULL; return NULL; } sethbmsg( str::stream() << "syncing to: " << closest->fullName(), 0); + _currentSyncTarget = closest; return const_cast(closest); }