mongo::Chunk Class Reference
#include <chunk.h>
List of all members.
Public Member Functions |
void | appendShortVersion (const char *name, BSONObjBuilder &b) |
| Chunk (ChunkManager *info, const BSONObj &min, const BSONObj &max, const Shard &shard) |
| Chunk (ChunkManager *info) |
bool | contains (const BSONObj &obj) const |
int | countObjects (int maxcount=0) const |
string | genID () const |
ShardChunkVersion | getLastmod () const |
const ChunkManager * | getManager () const |
const BSONObj & | getMax () const |
const BSONObj & | getMin () const |
const char * | getNS () |
string | getns () const |
long | getPhysicalSize () const |
Shard | getShard () const |
bool | maxIsInf () const |
bool | minIsInf () const |
bool | moveAndCommit (const Shard &to, long long chunkSize, BSONObj &res) |
bool | moveIfShould (ChunkPtr newShard=ChunkPtr()) |
ChunkPtr | multiSplit (const vector< BSONObj > &splitPoints, BSONObj &res) |
bool | operator!= (const Chunk &s) const |
bool | operator== (const Chunk &s) const |
void | pickMedianKey (BSONObj &medianKey) const |
void | pickSplitVector (vector< BSONObj > &splitPoints, int chunkSize, int maxPoints=0, int maxObjs=0) const |
void | serialize (BSONObjBuilder &to, ShardChunkVersion myLastMod=0) |
void | setLastmod (ShardChunkVersion v) |
void | setMax (const BSONObj &o) |
void | setMin (const BSONObj &o) |
ChunkPtr | singleSplit (bool force, BSONObj &res) |
bool | splitIfShould (long dataWritten) |
string | toString () const |
void | unserialize (const BSONObj &from) |
Static Public Member Functions |
static string | genID (const string &ns, const BSONObj &min) |
Static Public Attributes |
static string | chunkMetadataNS |
static int | MaxChunkSize |
static int | MaxObjectPerChunk |
Private Member Functions |
BSONObj | _getExtremeKey (int sort) const |
void | _setDataWritten () |
ShardKeyPattern | skey () const |
Private Attributes |
long | _dataWritten |
ShardChunkVersion | _lastmod |
ChunkManager * | _manager |
BSONObj | _max |
BSONObj | _min |
Shard | _shard |
Friends |
ostream & | operator<< (ostream &out, const Chunk &c) |
Detailed Description
config.chunks { ns : "alleyinsider.fs.chunks" , min : {} , max : {} , server : "localhost:30001" }
x is in a shard iff min <= x < max
Definition at line 54 of file chunk.h.
Constructor & Destructor Documentation
Member Function Documentation
BSONObj mongo::Chunk::_getExtremeKey |
( |
int |
sort |
) |
const [private] |
if sort 1, return lowest key if sort -1, return highest key will return empty object if have none
void mongo::Chunk::_setDataWritten |
( |
|
) |
[private] |
initializes _dataWritten with a random value so that a mongos restart wouldn't cause delay in splitting
void mongo::Chunk::appendShortVersion |
( |
const char * |
name, |
|
|
BSONObjBuilder & |
b | |
|
) |
| | |
bool mongo::Chunk::contains |
( |
const BSONObj & |
obj |
) |
const |
int mongo::Chunk::countObjects |
( |
int |
maxcount = 0 |
) |
const |
static string mongo::Chunk::genID |
( |
const string & |
ns, |
|
|
const BSONObj & |
min | |
|
) |
| | [static] |
string mongo::Chunk::genID |
( |
|
) |
const [inline] |
const ChunkManager* mongo::Chunk::getManager |
( |
|
) |
const [inline] |
const BSONObj& mongo::Chunk::getMax |
( |
|
) |
const [inline] |
const BSONObj& mongo::Chunk::getMin |
( |
|
) |
const [inline] |
const char* mongo::Chunk::getNS |
( |
|
) |
[inline] |
string mongo::Chunk::getns |
( |
|
) |
const |
long mongo::Chunk::getPhysicalSize |
( |
|
) |
const |
- Returns:
- size of shard in bytes talks to mongod to do this
Shard mongo::Chunk::getShard |
( |
|
) |
const [inline] |
bool mongo::Chunk::maxIsInf |
( |
|
) |
const |
bool mongo::Chunk::minIsInf |
( |
|
) |
const |
bool mongo::Chunk::moveAndCommit |
( |
const Shard & |
to, |
|
|
long long |
chunkSize, |
|
|
BSONObj & |
res | |
|
) |
| | |
Issues a migrate request for this chunk
- Parameters:
-
| to | shard to move this chunk to |
| chunSize | maximum number of bytes beyond which the migrate should no go trhough |
| res | the object containing details about the migrate execution |
- Returns:
- true if move was successful
moves either this shard or newShard if it makes sense too
- Returns:
- whether or not a shard was moved
Splits this chunk at the given key (or keys)
- Parameters:
-
| splitPoints | the vector of keys that should be used to divide this chunk |
| res | the object containing details about the split execution |
- Returns:
- shared pointer to the first new Chunk or null pointer if failed
bool mongo::Chunk::operator!= |
( |
const Chunk & |
s |
) |
const [inline] |
bool mongo::Chunk::operator== |
( |
const Chunk & |
s |
) |
const |
void mongo::Chunk::pickMedianKey |
( |
BSONObj & |
medianKey |
) |
const |
Asks the mongod holding this chunk to find a key that approximately divides this chunk in two
- Parameters:
-
| medianKey | the key that divides this chunk, if there is one, or empty |
void mongo::Chunk::pickSplitVector |
( |
vector< BSONObj > & |
splitPoints, |
|
|
int |
chunkSize, |
|
|
int |
maxPoints = 0 , |
|
|
int |
maxObjs = 0 | |
|
) |
| | const |
- Parameters:
-
| splitPoints | vector to be filled in |
| chunkSize | chunk size to target in bytes |
| maxPoints | limits the number of split points that are needed, zero is max (optional) |
| maxObjs | limits the number of objects in each chunk, zero is as max (optional) |
void mongo::Chunk::setMax |
( |
const BSONObj & |
o |
) |
[inline] |
void mongo::Chunk::setMin |
( |
const BSONObj & |
o |
) |
[inline] |
Splits this chunk at a non-specificed split key to be chosen by the mongod holding this chunk.
- Parameters:
-
| force | if set to true, will split the chunk regardless if the split is really necessary size wise if set to false, will only split if the chunk has reached the currently desired maximum size |
| res | the object containing details about the split execution |
- Returns:
- if found a key, return a pointer to the first chunk, otherwise return a null pointer
bool mongo::Chunk::splitIfShould |
( |
long |
dataWritten |
) |
|
if the amount of data written nears the max size of a shard then we check the real size, and if its too big, we split
- Returns:
- if something was split
string mongo::Chunk::toString |
( |
|
) |
const |
void mongo::Chunk::unserialize |
( |
const BSONObj & |
from |
) |
|
Friends And Related Function Documentation
ostream& operator<< |
( |
ostream & |
out, |
|
|
const Chunk & |
c | |
|
) |
| | [friend] |
Member Data Documentation
The documentation for this class was generated from the following file: