summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Stearn <redbeard0531@gmail.com>2010-10-26 00:46:46 -0400
committerMathias Stearn <redbeard0531@gmail.com>2010-10-26 01:19:18 -0400
commit1dcc81e34eba2f590b387358a25643aa5d12d274 (patch)
tree7e99e723cd51fadd2060eed182b9d57e2b08bc48
parente9429566d75a8aaac3b8fdf70f174dca964d04b7 (diff)
downloadmongo-1dcc81e34eba2f590b387358a25643aa5d12d274.tar.gz
mongo_vstudio.cpp update
-rw-r--r--shell/mongo_vstudio.cpp37
1 files changed, 33 insertions, 4 deletions
diff --git a/shell/mongo_vstudio.cpp b/shell/mongo_vstudio.cpp
index 8b23ef15244..c1a224d7e45 100644
--- a/shell/mongo_vstudio.cpp
+++ b/shell/mongo_vstudio.cpp
@@ -654,11 +654,13 @@ const char * jsconcatcode =
"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.conf() get the current configuration object from local.system.replset\");\n"
+ "print(\"\\trs.reconfig(cfg) updates the configuration of a running replica set with 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(\"\\trs.remove(hostportstr) remove a host from the replica set\");\n"
"print(\"\\trs.slaveOk() shorthand for db.getMongo().setSlaveOk()\");\n"
"print();\n"
"print(\"\\tdb.isMaster() check who is primary\");\n"
@@ -668,6 +670,9 @@ const char * jsconcatcode =
"rs.status = function () { return db._adminCommand(\"replSetGetStatus\"); }\n"
"rs.isMaster = function () { return db.isMaster(); }\n"
"rs.initiate = function (c) { return db._adminCommand({ replSetInitiate: c }); }\n"
+ "rs.reconfig = function(cfg) {\n"
+ "cfg.version = rs.conf().version + 1;\n"
+ "return db._adminCommand({ replSetReconfig: cfg });}\n"
"rs.add = function (hostport, arb) {\n"
"var cfg = hostport;\n"
"var local = db.getSisterDB(\"local\");\n"
@@ -687,6 +692,18 @@ const char * jsconcatcode =
"rs.stepDown = function () { return db._adminCommand({ replSetStepDown:true}); }\n"
"rs.addArb = function (hn) { return this.add(hn, true); }\n"
"rs.conf = function () { return db.getSisterDB(\"local\").system.replset.findOne(); }\n"
+ "rs.remove = function (hn) {\n"
+ "var local = db.getSisterDB(\"local\");\n"
+ "assert(local.system.replset.count() <= 1, \"error: local.system.replset has unexpected contents\");\n"
+ "var c = local.system.replset.findOne();\n"
+ "assert(c, \"no config object retrievable from local.system.replset\");\n"
+ "c.version++;\n"
+ "for (var i in c.members) {\n"
+ "if (c.members[i].host == hn) {\n"
+ "c.members.splice(i, 1);\n"
+ "return db._adminCommand({ replSetReconfig : c});}}\n"
+ "return \"error: couldn't find \"+hn+\" in \"+tojson(c.members);\n"
+ "};\n"
"help = shellHelper.help = function (x) {\n"
"if (x == \"connect\") {\n"
"print(\"\\nNormally one specifies the server on the mongo shell command line. Run mongo --help to see those options.\");\n"
@@ -1372,7 +1389,17 @@ const char * jsconcatcode =
"var e = n.next();\n"
"if (!verbose) {\n"
"delete e.allPlans;\n"
- "delete e.oldPlan;}\n"
+ "delete e.oldPlan;\n"
+ "if (e.shards){\n"
+ "for (var key in e.shards){\n"
+ "var s = e.shards[key];\n"
+ "if(s.length === undefined){\n"
+ "delete s.allPlans;\n"
+ "delete s.oldPlan;\n"
+ "} else {\n"
+ "for (var i=0; i < s.length; i++){\n"
+ "delete s[i].allPlans;\n"
+ "delete s[i].oldPlan;}}}}}\n"
"return e;}\n"
"DBQuery.prototype.snapshot = function(){\n"
"this._ensureSpecial();\n"
@@ -1452,6 +1479,8 @@ const char * jsconcatcode =
"return __magicNoPrint;}\n"
"DBCollection.prototype.getFullName = function(){\n"
"return this._fullName;}\n"
+ "DBCollection.prototype.getMongo = function(){\n"
+ "return this._db.getMongo();}\n"
"DBCollection.prototype.getDB = function(){\n"
"return this._db;}\n"
"DBCollection.prototype._dbCommand = function( cmd , params ){\n"
@@ -1516,8 +1545,8 @@ const char * jsconcatcode =
"obj[key] = tmp[key];}}\n"
"this._mongo.insert( this._fullName , obj );\n"
"this._lastID = obj._id;}\n"
- "DBCollection.prototype.remove = function( t ){\n"
- "this._mongo.remove( this._fullName , this._massageObject( t ) );}\n"
+ "DBCollection.prototype.remove = function( t , justOne ){\n"
+ "this._mongo.remove( this._fullName , this._massageObject( t ) , justOne ? true : false );}\n"
"DBCollection.prototype.update = function( query , obj , upsert , multi ){\n"
"assert( query , \"need a query\" );\n"
"assert( obj , \"need an object\" );\n"