mongo::ShardingState Class Reference

#include <d_logic.h>

List of all members.

Public Member Functions

void appendInfo (BSONObjBuilder &b)
void donateChunk (const string &ns, const BSONObj &min, const BSONObj &max, ShardChunkVersion version)
void enable (const string &server)
bool enabled () const
const string & getConfigServer () const
ShardChunkManagerPtr getShardChunkManager (const string &ns)
const ConfigVersion getVersion (const string &ns) const
void gotShardHost (string host)
void gotShardName (const string &name)
bool hasVersion (const string &ns, ConfigVersion &version)
bool hasVersion (const string &ns)
bool inCriticalMigrateSection ()
bool needShardChunkManager (const string &ns) const
void resetShardingState ()
void resetVersion (const string &ns)
 ShardingState ()
void splitChunk (const string &ns, const BSONObj &min, const BSONObj &max, const vector< BSONObj > &splitKeys, ShardChunkVersion version)
bool trySetVersion (const string &ns, ConfigVersion &version)
void undoDonateChunk (const string &ns, const BSONObj &min, const BSONObj &max, ShardChunkVersion version)

Private Types

typedef map< string,
ShardChunkManagerPtr
ChunkManagersMap

Private Attributes

ChunkManagersMap _chunks
string _configServer
bool _enabled
mongo::mutex _mutex
string _shardHost
string _shardName

Detailed Description

Definition at line 38 of file d_logic.h.


Member Typedef Documentation

Definition at line 151 of file d_logic.h.


Constructor & Destructor Documentation

mongo::ShardingState::ShardingState (  ) 

Member Function Documentation

void mongo::ShardingState::appendInfo ( BSONObjBuilder b  ) 
void mongo::ShardingState::donateChunk ( const string &  ns,
const BSONObj min,
const BSONObj max,
ShardChunkVersion  version 
)

Creates and installs a new chunk manager for a given collection by "forgetting" about one of its chunks. The new manager uses the provided version, which has to be higher than the current manager's. One exception: if the forgotten chunk is the last one in this shard for the collection, version has to be 0.

If it runs successfully, clients need to grab the new version to access the collection.

Parameters:
ns the collection
min max the chunk to eliminate from the current manager
version at which the new manager should be at
void mongo::ShardingState::enable ( const string &  server  ) 
bool mongo::ShardingState::enabled (  )  const [inline]

Definition at line 42 of file d_logic.h.

const string& mongo::ShardingState::getConfigServer (  )  const [inline]

Definition at line 43 of file d_logic.h.

ShardChunkManagerPtr mongo::ShardingState::getShardChunkManager ( const string &  ns  ) 
const ConfigVersion mongo::ShardingState::getVersion ( const string &  ns  )  const
void mongo::ShardingState::gotShardHost ( string  host  ) 
void mongo::ShardingState::gotShardName ( const string &  name  ) 
bool mongo::ShardingState::hasVersion ( const string &  ns,
ConfigVersion version 
)
bool mongo::ShardingState::hasVersion ( const string &  ns  ) 
bool mongo::ShardingState::inCriticalMigrateSection (  ) 
bool mongo::ShardingState::needShardChunkManager ( const string &  ns  )  const
void mongo::ShardingState::resetShardingState (  ) 

Reverts back to a state where this mongod is not sharded.

void mongo::ShardingState::resetVersion ( const string &  ns  ) 

Uninstalls the manager for a given collection. This should be used when the collection is dropped.

NOTE: An existing collection with no chunks on this shard will have a manager on version 0, which is different than a a dropped collection, which will not have a manager.

TODO When sharding state is enabled, absolutely all collections should have a manager. (The non-sharded ones are a be degenerate case of one-chunk collections). For now, a dropped collection and an non-sharded one are indistinguishable (SERVER-1849)

Parameters:
ns the collection to be dropped
void mongo::ShardingState::splitChunk ( const string &  ns,
const BSONObj min,
const BSONObj max,
const vector< BSONObj > &  splitKeys,
ShardChunkVersion  version 
)

Creates and installs a new chunk manager for a given collection by splitting one of its chunks in two or more. The version for the first split chunk should be provided. The subsequent chunks' version would be the latter with the minor portion incremented.

The effect on clients will depend on the version used. If the major portion is the same as the current shards, clients shouldn't perceive the split.

Parameters:
ns the collection
min max the chunk that should be split
splitKeys point in which to split
version at which the new manager should be at
bool mongo::ShardingState::trySetVersion ( const string &  ns,
ConfigVersion version 
)

Requests to access a collection at a certain version. If the collection's manager is not at that version it will try to update itself to the newest version. The request is only granted if the version is the current or the newest one.

Parameters:
ns collection to be accessed
version (IN) the client belive this collection is on and (OUT) the version the manager is actually in
Returns:
true if the access can be allowed at the provided version
void mongo::ShardingState::undoDonateChunk ( const string &  ns,
const BSONObj min,
const BSONObj max,
ShardChunkVersion  version 
)

Creates and installs a new chunk manager for a given collection by reclaiming a previously donated chunk. The previous manager's version has to be provided.

If it runs successfully, clients that became stale by the previous donateChunk will be able to access the collection again.

Parameters:
ns the collection
min max the chunk to reclaim and add to the current manager
version at which the new manager should be at

Member Data Documentation

Definition at line 152 of file d_logic.h.

Definition at line 141 of file d_logic.h.

Definition at line 139 of file d_logic.h.

Definition at line 147 of file d_logic.h.

Definition at line 144 of file d_logic.h.

Definition at line 143 of file d_logic.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:58 2013