mongo::ShardChunkManager Class Reference
#include <d_chunk_manager.h>
List of all members.
Public Member Functions |
bool | belongsToMe (const BSONObj &obj) const |
ShardChunkManager * | cloneMinus (const BSONObj &min, const BSONObj &max, const ShardChunkVersion &version) |
ShardChunkManager * | clonePlus (const BSONObj &min, const BSONObj &max, const ShardChunkVersion &version) |
ShardChunkManager * | cloneSplit (const BSONObj &min, const BSONObj &max, const vector< BSONObj > &splitKeys, const ShardChunkVersion &version) |
BSONObj | getKey () const |
bool | getNextChunk (const BSONObj &lookupKey, BSONObj *foundMin, BSONObj *foundMax) const |
unsigned | getNumChunks () const |
ShardChunkVersion | getVersion () const |
| ShardChunkManager (const BSONObj &collectionDoc, const BSONArray &chunksDoc) |
| ShardChunkManager (const string &configServer, const string &ns, const string &shardName) |
string | toString () const |
| ~ShardChunkManager () |
Private Types |
typedef map< BSONObj, BSONObj,
BSONObjCmp > | RangeMap |
Private Member Functions |
void | _assertChunkExists (const BSONObj &min, const BSONObj &max) const |
void | _fillChunks (DBClientCursorInterface *cursor) |
void | _fillCollectionKey (const BSONObj &collectionDoc) |
void | _fillRanges () |
| ShardChunkManager () |
Private Attributes |
RangeMap | _chunksMap |
BSONObj | _key |
RangeMap | _rangesMap |
ShardChunkVersion | _version |
Detailed Description
Controls the boundaries of all the chunks for a given collection that live in this shard.
ShardChunkManager instances never change after construction. There are methods provided that would generate a new manager if new chunks are added, subtracted, or split.
TODO The responsibility of maintaining the version for a shard is still shared between this class and its caller. The manager does check corner cases (e.g. cloning out the last chunk generates a manager with version 0) but ultimately still cannot be responsible to set all versions. Currently, they are a function of the global state as opposed to the per-shard one.
Definition at line 40 of file d_chunk_manager.h.
Member Typedef Documentation
Constructor & Destructor Documentation
mongo::ShardChunkManager::ShardChunkManager |
( |
const string & |
configServer, |
|
|
const string & |
ns, |
|
|
const string & |
shardName | |
|
) |
| | |
Loads the ShardChunkManager with all boundaries for chunks of a given collection that live in an given shard.
- Parameters:
-
| configServer | name of the server where the configDB currently is. Can be empty to indicate that the configDB is running locally |
| ns | namespace for the collections whose chunks we're interested |
| shardName | name of the shard that this chunk matcher should track |
This constructor throws if collection is dropped/malformed and on connectivity errors
mongo::ShardChunkManager::ShardChunkManager |
( |
const BSONObj & |
collectionDoc, |
|
|
const BSONArray & |
chunksDoc | |
|
) |
| | |
Same as the regular constructor but used in unittest (no access to configDB required).
- Parameters:
-
| collectionDoc | simulates config.collection's entry for one colleciton |
| chunksDocs | simulates config.chunks' entries for one collection's shard |
mongo::ShardChunkManager::~ShardChunkManager |
( |
|
) |
[inline] |
mongo::ShardChunkManager::ShardChunkManager |
( |
|
) |
[inline, private] |
Member Function Documentation
void mongo::ShardChunkManager::_assertChunkExists |
( |
const BSONObj & |
min, |
|
|
const BSONObj & |
max | |
|
) |
| | const [private] |
throws if the exact chunk is not in the chunks' map
void mongo::ShardChunkManager::_fillCollectionKey |
( |
const BSONObj & |
collectionDoc |
) |
[private] |
void mongo::ShardChunkManager::_fillRanges |
( |
|
) |
[private] |
bool mongo::ShardChunkManager::belongsToMe |
( |
const BSONObj & |
obj |
) |
const |
Checks whether a document belongs to this shard.
- Parameters:
-
| obj | document containing sharding keys (and, optionally, other attributes) |
- Returns:
- true if shards hold the object
Generates a new manager based on 'this's state minus a given chunk.
- Parameters:
-
| min | max chunk boundaries for the chunk to subtract |
| version | that the resulting manager should be at. The version has to be higher than the current one. When cloning away the last chunk, verstion must be 0. |
- Returns:
- a new ShardChunkManager, to be owned by the caller
Generates a new manager based on 'this's state plus a given chunk.
- Parameters:
-
| min | max chunk boundaries for the chunk to add |
| version | that the resulting manager should be at. It can never be 0, though (see CloneMinus). |
- Returns:
- a new ShardChunkManager, to be owned by the caller
Generates a new manager by splitting an existing chunk at one or more points.
- Parameters:
-
| min | max boundaries of chunk to be split |
| splitKeys | points to split original chunk at |
| version | to be used in first chunk. The subsequent chunks would increment the minor version. |
- Returns:
- a new ShardChunkManager with the chunk split, to be owned by the caller
BSONObj mongo::ShardChunkManager::getKey |
( |
|
) |
const [inline] |
bool mongo::ShardChunkManager::getNextChunk |
( |
const BSONObj & |
lookupKey, |
|
|
BSONObj * |
foundMin, |
|
|
BSONObj * |
foundMax | |
|
) |
| | const |
Given a chunk's min key (or empty doc), gets the boundary of the chunk following that one (the first).
- Parameters:
-
| lookupKey | is the min key for a previously obtained chunk or the empty document |
| foundMin | IN/OUT min for chunk following the one starting at lookupKey |
| foundMax | IN/OUT max for the above chunk |
- Returns:
- true if the chunk returned is the last one
unsigned mongo::ShardChunkManager::getNumChunks |
( |
|
) |
const [inline] |
string mongo::ShardChunkManager::toString |
( |
|
) |
const |
Member Data Documentation
The documentation for this class was generated from the following file: