File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -1165,8 +1165,8 @@ DBCollection.prototype.getShardDistribution = function() {
11651165
11661166 numChunks += chunks . length ;
11671167
1168- var estChunkData = shardStats . size / chunks . length ;
1169- var estChunkCount = Math . floor ( shardStats . count / chunks . length ) ;
1168+ var estChunkData = ( chunks . length == 0 ) ? 0 : shardStats . size / chunks . length ;
1169+ var estChunkCount = ( chunks . length == 0 ) ? 0 : Math . floor ( shardStats . count / chunks . length ) ;
11701170
11711171 print ( " data : " + sh . _dataFormat ( shardStats . size ) + " docs : " + shardStats . count +
11721172 " chunks : " + chunks . length ) ;
@@ -1180,8 +1180,10 @@ DBCollection.prototype.getShardDistribution = function() {
11801180 for ( var shard in stats . shards ) {
11811181 var shardStats = stats . shards [ shard ] ;
11821182
1183- var estDataPercent = Math . floor ( shardStats . size / stats . size * 10000 ) / 100 ;
1184- var estDocPercent = Math . floor ( shardStats . count / stats . count * 10000 ) / 100 ;
1183+ var estDataPercent =
1184+ ( stats . size == 0 ) ? 0 : ( Math . floor ( shardStats . size / stats . size * 10000 ) / 100 ) ;
1185+ var estDocPercent =
1186+ ( stats . count == 0 ) ? 0 : ( Math . floor ( shardStats . count / stats . count * 10000 ) / 100 ) ;
11851187
11861188 print ( " Shard " + shard + " contains " + estDataPercent + "% data, " + estDocPercent +
11871189 "% docs in cluster, " + "avg obj size on shard : " +
Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ sh._getBalancerStatus = function() {
2929} ;
3030
3131sh . _dataFormat = function ( bytes ) {
32+ if ( bytes == null ) {
33+ return "0B" ;
34+ }
35+
3236 if ( bytes < 1024 )
3337 return Math . floor ( bytes ) + "B" ;
3438 if ( bytes < 1024 * 1024 )
You can’t perform that action at this time.
0 commit comments