summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2011-04-15 02:44:10 -0400
committerEliot Horowitz <eliot@10gen.com>2011-04-15 02:44:10 -0400
commitbf09b1cc49bb2bff684dff1bf97043063d764016 (patch)
treeede556301cdb9a53d279e697e3daf525e312bb3e /shell
parent90372ab038501b527f40d67c581694a78e73a837 (diff)
downloadmongo-bf09b1cc49bb2bff684dff1bf97043063d764016.tar.gz
sharding helper
Diffstat (limited to 'shell')
-rw-r--r--shell/utils_sh.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/shell/utils_sh.js b/shell/utils_sh.js
new file mode 100644
index 00000000000..13a017d1871
--- /dev/null
+++ b/shell/utils_sh.js
@@ -0,0 +1,37 @@
+sh = function() { return "try sh.help();" }
+
+
+sh._checkMongos = function() {
+ var x = db.runCommand( "ismaster" );
+ if ( x.msg != "isdbgrid" )
+ throw "not connected to a mongos"
+}
+
+sh._adminCommand = function( cmd ) {
+ sh._checkMongos();
+ var res = db.getSisterDB( "admin" ).runCommand( cmd );
+
+ if ( res == null || ! res.ok ) {
+ print( "command failed: " + tojson( res ) )
+ }
+
+ return res;
+}
+
+sh.help = function() {
+ print( "\tsh.enableSharding(dbname) enables sharding on the database dbname" )
+ print( "\tsh.status() prints a general overview of the cluster" )
+}
+
+sh.status = function( verbose , configDB ) {
+ // TODO: move the actual commadn here
+ printShardingStatus( configDB , verbose );
+}
+
+sh.enableSharding = function( dbname ) {
+ assert( dbname , "need a valid dbname" )
+ sh._adminCommand( { enableSharding : dbname } )
+}
+
+
+