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 ChunkManagergetManager () const
const BSONObjgetMax () const
const BSONObjgetMin () 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

mongo::Chunk::Chunk ( ChunkManager info  ) 
mongo::Chunk::Chunk ( ChunkManager info,
const BSONObj min,
const BSONObj max,
const Shard shard 
)

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]

Definition at line 406 of file chunk.h.

ShardChunkVersion mongo::Chunk::getLastmod (  )  const [inline]

Definition at line 90 of file chunk.h.

const ChunkManager* mongo::Chunk::getManager (  )  const [inline]

Definition at line 190 of file chunk.h.

const BSONObj& mongo::Chunk::getMax (  )  const [inline]

Definition at line 71 of file chunk.h.

const BSONObj& mongo::Chunk::getMin (  )  const [inline]

Definition at line 70 of file chunk.h.

const char* mongo::Chunk::getNS (  )  [inline]

Definition at line 188 of file chunk.h.

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]

Definition at line 189 of file chunk.h.

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
bool mongo::Chunk::moveIfShould ( ChunkPtr  newShard = ChunkPtr()  ) 

moves either this shard or newShard if it makes sense too

Returns:
whether or not a shard was moved
ChunkPtr mongo::Chunk::multiSplit ( const vector< BSONObj > &  splitPoints,
BSONObj res 
)

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]

Definition at line 185 of file chunk.h.

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::serialize ( BSONObjBuilder to,
ShardChunkVersion  myLastMod = 0 
)
void mongo::Chunk::setLastmod ( ShardChunkVersion  v  )  [inline]

Definition at line 91 of file chunk.h.

void mongo::Chunk::setMax ( const BSONObj o  )  [inline]

Definition at line 73 of file chunk.h.

void mongo::Chunk::setMin ( const BSONObj o  )  [inline]

Definition at line 72 of file chunk.h.

ChunkPtr mongo::Chunk::singleSplit ( bool  force,
BSONObj res 
)

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
ShardKeyPattern mongo::Chunk::skey (  )  const [private]
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]

Definition at line 183 of file chunk.h.


Member Data Documentation

Definition at line 205 of file chunk.h.

Definition at line 201 of file chunk.h.

Definition at line 196 of file chunk.h.

Definition at line 199 of file chunk.h.

Definition at line 198 of file chunk.h.

Definition at line 200 of file chunk.h.

Definition at line 174 of file chunk.h.

Definition at line 175 of file chunk.h.

Definition at line 176 of file chunk.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


mongodb
Author(s): Nate Koenig
autogenerated on Fri Jan 11 12:15:54 2013