summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-11-06 13:55:00 -0500
committerEliot Horowitz <eliot@10gen.com>2009-11-06 13:55:00 -0500
commit697ce04a25a2a0635227c6e8c8ef8ca01dc41ebf (patch)
tree2646cec8f2cc06856976861df88bf509b5f0b1ff /shell
parent96047d90daca1498120c8324d3ba24461d55b981 (diff)
downloadmongo-697ce04a25a2a0635227c6e8c8ef8ca01dc41ebf.tar.gz
some utils for printing out sharding info
Diffstat (limited to 'shell')
-rw-r--r--shell/servers.js41
1 files changed, 40 insertions, 1 deletions
diff --git a/shell/servers.js b/shell/servers.js
index e01807149da..56d2738a1c9 100644
--- a/shell/servers.js
+++ b/shell/servers.js
@@ -112,7 +112,8 @@ ShardingTest = function( testName , numServers , verboseLevel , numMongos ){
this._serverNames = [];
for ( var i=0; i<numServers; i++){
- var conn = startMongod( { port : 30000 + i , dbpath : "/data/db/" + testName + i , noprealloc : "" , smallfiles : "" } );
+ var conn = startMongod( { port : 30000 + i , dbpath : "/data/db/" + testName + i ,
+ noprealloc : "" , smallfiles : "" , oplogSize : "2" } );
conn.name = "localhost:" + ( 30000 + i );
this._connections.push( conn );
@@ -198,6 +199,44 @@ ShardingTest.prototype.printChunks = function( ns ){
print( this.getChunksString( ns ) );
}
+ShardingTest.prototype.printShardingStatus = function(){
+ printShardingStatus( this.config );
+}
+
+printShardingStatus = function( configDB ){
+ var raw = "";
+ var output = function(s){
+ raw += s + "\n";
+ }
+ output( "--- Sharding Status --- " );
+ output( " sharding version: " + tojson( configDB.getCollection( "version" ).findOne() ) );
+
+ output( " shards:" );
+ configDB.shards.find().forEach(
+ function(z){
+ output( " " + tojson(z) );
+ }
+ );
+
+ output( " databases:" );
+ configDB.databases.find().sort( { name : 1 } ).forEach(
+ function(z){
+ output( "\t" + tojson(z,"",true) );
+
+ output( "\t\tmy chunks" );
+
+ configDB.chunks.find( { "ns" : new RegExp( "^" + z.name ) } ).sort( { ns : 1 } ).forEach(
+ function(z){
+ output( "\t\t\t" + z.ns + " " + tojson( z.min ) + " -->> " + tojson( z.max ) +
+ " on : " + z.shard + " " + tojson( z.lastmod ) );
+ }
+ );
+ }
+ );
+
+ print( raw );
+}
+
ShardingTest.prototype.sync = function(){
this.adminCommand( "connpoolsync" );
}