jstests/sharding/balancing_sessions_collection.js
/*
 * Returns true if the chunks for the sessions collection are evenly distributed across the
 * given shards. That is, the number of chunks on the most loaded shard and on the least
 * loaded shard differs by no more than 1.
 */
Returns true if the chunks for the sessions collection are evenly distributed across the
given shards. That is, the number of chunks on the most loaded shard and on the least
loaded shard differs by no more than 1.
Returns true if the chunks for the sessions collection are evenly distributed across the given shards . That is the number of chunks on the most loaded shard and on the least loaded shard differs by no more than 1 .
function isBalanced(shardNames) {
    const expectedMinNumChunksPerShard = Math.floor(kExpectedNumChunks / shardNames.length);
    let minNumChunks = Number.MAX_VALUE;
    let maxNumChunks = 0;
    for (const shardName of shardNames) {
        const numChunks = getNumChunksOnShard(shardName);
        minNumChunks = Math.min(numChunks, minNumChunks);
        maxNumChunks = Math.max(numChunks, maxNumChunks);
    }
    return (maxNumChunks - minNumChunks <= 1) && (minNumChunks == expectedMinNumChunksPerShard);
}
function isBalanced ( shardNames ) { const expectedMinNumChunksPerShard = Math . floor ( kExpectedNumChunks / shardNames . length ) ; let minNumChunks = Number . MAX_VALUE ; let maxNumChunks = 0 ; for ( const shardName of shardNames ) { const numChunks = getNumChunksOnShard ( shardName ) ; minNumChunks = Math . min ( numChunks , minNumChunks ) ; maxNumChunks = Math . max ( numChunks , maxNumChunks ) ; } return ( maxNumChunks - minNumChunks <= 1 ) && ( minNumChunks == expectedMinNumChunksPerShard ) ; }
Returns true if the chunks for the sessions collection are evenly distributed across the
 given shards.
Returns true if the chunks for the sessions collection are evenly distributed across the given shards .