0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

default to using rsGetStatus for slaveReplInfo SERVER-3376

This commit is contained in:
Kristina 2011-07-07 15:48:06 -04:00
parent e987d4c8ad
commit 5f70df96b5
2 changed files with 11 additions and 9 deletions

View File

@ -712,7 +712,7 @@ DB.prototype.printSlaveReplicationInfo = function() {
print("\t syncedTo: " + st.toString() ); print("\t syncedTo: " + st.toString() );
var ago = (now-st)/1000; var ago = (now-st)/1000;
var hrs = Math.round(ago/36)/100; var hrs = Math.round(ago/36)/100;
print("\t\t = " + Math.round(ago) + "secs ago (" + hrs + "hrs)"); print("\t\t = " + Math.round(ago) + " secs ago (" + hrs + "hrs)");
}; };
function g(x) { function g(x) {
@ -743,13 +743,14 @@ DB.prototype.printSlaveReplicationInfo = function() {
}; };
var L = this.getSiblingDB("local"); var L = this.getSiblingDB("local");
if( L.sources.count() != 0 ) {
L.sources.find().forEach(g); if (L.system.replset.count() != 0) {
}
else if (L.system.replset.count() != 0) {
var status = this.adminCommand({'replSetGetStatus' : 1}); var status = this.adminCommand({'replSetGetStatus' : 1});
status.members.forEach(r); status.members.forEach(r);
} }
else if( L.sources.count() != 0 ) {
L.sources.find().forEach(g);
}
else { else {
print("local.sources is empty; is this db a --slave?"); print("local.sources is empty; is this db a --slave?");
return; return;

View File

@ -2440,13 +2440,14 @@ const StringData _jscode_raw_db =
"};\n" "};\n"
"\n" "\n"
"var L = this.getSiblingDB(\"local\");\n" "var L = this.getSiblingDB(\"local\");\n"
"if( L.sources.count() != 0 ) {\n" "\n"
"L.sources.find().forEach(g);\n" "if (L.system.replset.count() != 0) {\n"
"}\n"
"else if (L.system.replset.count() != 0) {\n"
"var status = this.adminCommand({'replSetGetStatus' : 1});\n" "var status = this.adminCommand({'replSetGetStatus' : 1});\n"
"status.members.forEach(r);\n" "status.members.forEach(r);\n"
"}\n" "}\n"
"else if( L.sources.count() != 0 ) {\n"
"L.sources.find().forEach(g);\n"
"}\n"
"else {\n" "else {\n"
"print(\"local.sources is empty; is this db a --slave?\");\n" "print(\"local.sources is empty; is this db a --slave?\");\n"
"return;\n" "return;\n"