mongo::Balancer Class Reference
#include <balance.h>
List of all members.
Detailed Description
The balancer is a background task that tries to keep the number of chunks across all servers of the cluster even. Although every mongos will have one balancer running, only one of them will be active at the any given point in time. The balancer uses a 'DistributedLock' for that coordination.
The balancer does act continuously but in "rounds". At a given round, it would decide if there is an imbalance by checking the difference in chunks between the most and least loaded shards. It would issue a request for a chunk migration per round, if it found so.
Definition at line 36 of file balance.h.
Member Typedef Documentation
Constructor & Destructor Documentation
mongo::Balancer::Balancer |
( |
|
) |
|
virtual mongo::Balancer::~Balancer |
( |
|
) |
[virtual] |
Member Function Documentation
bool mongo::Balancer::_checkOIDs |
( |
|
) |
[private] |
- Returns:
- true if all the servers listed in configdb as being shards are reachable and are distinct processes
Gathers all the necessary information about shards and chunks, and decides whether there are candidate chunks to be moved.
- Parameters:
-
| conn | is the connection with the config server(s) |
| candidateChunks | (IN/OUT) filled with candidate chunks, one per collection, that could possibly be moved |
bool mongo::Balancer::_init |
( |
|
) |
[private] |
Checks that the balancer can connect to all servers it needs to do its job.
- Returns:
- true if balancing can be started
This method throws on a network exception
int mongo::Balancer::_moveChunks |
( |
const vector< CandidateChunkPtr > * |
candidateChunks |
) |
[private] |
Issues chunk migration request, one at a time.
- Parameters:
-
| candidateChunks | possible chunks to move |
- Returns:
- number of chunks effectively moved
void mongo::Balancer::_ping |
( |
DBClientBase & |
conn |
) |
[private] |
Marks this balancer as being live on the config server(s).
- Parameters:
-
| conn | is the connection with the config server(s) |
virtual string mongo::Balancer::name |
( |
|
) |
const [inline, virtual] |
virtual void mongo::Balancer::run |
( |
|
) |
[virtual] |
define this to do your work. after this returns, state is set to done. after this returns, deleted if deleteSelf true.
NOTE: if run() throws, the exception will be caught within 'this' object and will ultimately lead to the BackgroundJob's thread being finished, as if run() returned.
Implements mongo::BackgroundJob.
Member Data Documentation
The documentation for this class was generated from the following file: