From 61730dca01746a5eb7faada07fa16bbe52460157 Mon Sep 17 00:00:00 2001 From: Shaun Verch Date: Tue, 20 May 2014 12:49:37 -0400 Subject: SERVER-13985 Remove server side js usage from printShardingStatus (cherry picked from commit df9cb2c79f98f5ab5471a95b36e7689600d686d2) --- src/mongo/shell/shardingtest.js | 9 +++++++-- 1 file 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; -- cgit v1.2.1