summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun Verch <shaun.verch@mongodb.com>2014-05-20 12:49:37 -0400
committerRamon Fernandez <ramon.fernandez@mongodb.com>2015-09-02 16:45:54 -0400
commit61730dca01746a5eb7faada07fa16bbe52460157 (patch)
treef0b964255d2c43f6173968fc7620b7ed125f5417
parent2abbaa67383f64d8b5e6cd747c5b0abf5f370335 (diff)
downloadmongo-61730dca01746a5eb7faada07fa16bbe52460157.tar.gz
SERVER-13985 Remove server side js usage from printShardingStatus
(cherry picked from commit df9cb2c79f98f5ab5471a95b36e7689600d686d2)
-rw-r--r--src/mongo/shell/shardingtest.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mongo/shell/shardingtest.js b/src/mongo/shell/shardingtest.js
index 944306fbb19..c2fb575c13e 100644
--- a/src/mongo/shell/shardingtest.js
+++ b/src/mongo/shell/shardingtest.js
@@ -665,8 +665,13 @@ printShardingStatus = function( configDB , verbose ){
output( "\t\t\tshard key: " + tojson(coll.key) );
output( "\t\t\tchunks:" );
- res = configDB.chunks.group( { cond : { ns : coll._id } , key : { shard : 1 },
- reduce : function( doc , out ){ out.nChunks++; } , initial : { nChunks : 0 } } );
+ res = configDB.chunks.aggregate( { $match : { ns : coll._id } } ,
+ { $group : { _id : "$shard" ,
+ cnt : { $sum : 1 } } } ,
+ { $project : { _id : 0 ,
+ shard : "$_id" ,
+ nChunks : "$cnt" } } ,
+ { $sort : { shard : 1 } } ).toArray();
var totalChunks = 0;
res.forEach( function(z){
totalChunks += z.nChunks;