Tokutek/mongo — pull request #1029 by ankurcha (2014-03-24 20:29:26+00:00)
Title: mongos always uses the first shard as the primary shard

This change fixes issue #422

**Problem**

Vanilla mongodb had the `mem.mapped` property that was used to determine the shard that was least loaded. And whenever a new database was enabled for sharding, the mongos would place the database primary on that. This was broken when tokumx removed the `mem.mapped` attribute from the output of `serverStatus` command.

**Proposed change**

This change fixes this error by using the `listDatabases` command to get the `totalSize` of databases on disk for selecting the best shard to place the primary when enabling sharding on a new database.

In addition to the above change, the variable name has been changed to `_dataSize` and the accessor to `datasize()` as the old names were no longer representative of the data stored within them.

**Acceptance Criteria**

* The primary shard selection if based on the disk utilization size (as was the intent in vanilla mongodb) and spread out amongst all shards.
* All old functionality continues to work
* Existing sharded databases/collections are not affected by this change.