make more commands work with mongos SERVER-1462

This commit is contained in:
Mathias Stearn
2010-07-22 21:00:30 -04:00
parent 02978c9b73
commit dd79445bbb
9 changed files with 233 additions and 26 deletions

View File

@@ -649,40 +649,34 @@ const char * jsconcatcode =
"by = b[key];}\n"
"return Math.sqrt( Math.pow( by - ay , 2 ) +\n"
"Math.pow( bx - ax , 2 ) );}\n"
"rs = function () { return \"try rs.help()\"; }\n"
"rs = function () { \"try rs.help()\" }\n"
"rs.help = function () {\n"
"print(\"\\trs.status() { replSetGetStatus : 1 } checks repl set status\");\n"
"print(\"\\trs.initiate() { replSetInitiate : null } initiates set with default settings\");\n"
"print(\"\\trs.initiate(cfg) { replSetInitiate : cfg } initiates set with configuration cfg\");\n"
"print(\"\\trs.add(hostportstr) add a new member to the set with default attributes\");\n"
"print(\"\\trs.add(membercfgobj) add a new member to the set with extra attributes\");\n"
"print(\"\\trs.addArb(hostportstr) add a new member which is arbiterOnly:true\");\n"
"print(\"\\trs.stepDown() step down as primary (momentarily)\");\n"
"print(\"\\trs.conf() return configuration from local.system.replset\");\n"
"print();\n"
"print(\"\\tdb.isMaster() check who is primary\");\n"
"print();\n"
"print(\"\\tsee also http://<mongod_host>:28017/_replSet for additional diagnostic info\");}\n"
"print(\"\\tsee also http://<host>:28017/_replSet for additional diagnostic info\");}\n"
"rs.status = function () { return db._adminCommand(\"replSetGetStatus\"); }\n"
"rs.initiate = function (c) { return db._adminCommand({ replSetInitiate: c }); }\n"
"rs.add = function (hostport, arb) {\n"
"rs.add = function (hostport) {\n"
"var cfg = hostport;\n"
"var local = db.getSisterDB(\"local\");\n"
"assert(local.system.replset.count() <= 1, \"error: local.system.replset has unexpected contents\");\n"
"assert(local.system.replset.count() == 1, \"error: local.system.replset unexpected (or empty) contents\");\n"
"var c = local.system.replset.findOne();\n"
"assert(c, \"no config object retrievable from local.system.replset\");\n"
"c.version++;\n"
"var max = 0;\n"
"for (var i in c.members)\n"
"if (c.members[i]._id > max) max = c.members[i]._id;\n"
"if (isString(hostport)) {\n"
"if (isString(hostport))\n"
"cfg = { _id: max + 1, host: hostport };\n"
"if (arb)\n"
"cfg.arbiterOnly = true;}\n"
"c.members.push(cfg);\n"
"return db._adminCommand({ replSetReconfig: c });}\n"
"rs.stepDown = function () { return db._adminCommand({ replSetStepDown: 1 }); }\n"
"rs.addArb = function (hn) { return this.add(hn, true); }\n"
"rs.conf = function () { return db.getSisterDB(\"local\").system.replset.findOne(); }\n"
"help = shellHelper.help = function (x) {\n"
"if (x == \"connect\") {\n"
@@ -725,10 +719,10 @@ const char * jsconcatcode =
"return;}\n"
"print(\"\\t\" + \"db.help() help on db methods\");\n"
"print(\"\\t\" + \"db.mycoll.help() help on collection methods\");\n"
"print(\"\\t\" + \"rs.help() help on replica set methods\");\n"
"print(\"\\t\" + \"help connect connecting to a db help\");\n"
"print(\"\\t\" + \"help admin administrative help\");\n"
"print(\"\\t\" + \"help misc misc things to know\");\n"
"print(\"\\t\" + \"rs.help() help on replica set methods\");\n"
"print();\n"
"print(\"\\t\" + \"show dbs show database names\");\n"
"print(\"\\t\" + \"show collections show collections in current database\");\n"
@@ -1288,12 +1282,6 @@ const char * jsconcatcode =
"throw \"error: \" + tojson( ret );\n"
"this._numReturned++;\n"
"return ret;}\n"
"DBQuery.prototype.objsLeftInBatch = function(){\n"
"this._exec();\n"
"var ret = this._cursor.objsLeftInBatch();\n"
"if ( ret.$err )\n"
"throw \"error: \" + tojson( ret );\n"
"return ret;}\n"
"DBQuery.prototype.toArray = function(){\n"
"if ( this._arr )\n"
"return this._arr;\n"