diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-04-15 02:44:10 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-04-15 02:44:10 -0400 |
commit | bf09b1cc49bb2bff684dff1bf97043063d764016 (patch) | |
tree | ede556301cdb9a53d279e697e3daf525e312bb3e /shell | |
parent | 90372ab038501b527f40d67c581694a78e73a837 (diff) | |
download | mongo-bf09b1cc49bb2bff684dff1bf97043063d764016.tar.gz |
sharding helper
Diffstat (limited to 'shell')
-rw-r--r-- | shell/utils_sh.js | 37 |
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 } ) +} + + + |