本文整理汇总了C++中ShardChunkManagerPtr::getVersion方法的典型用法代码示例。如果您正苦于以下问题:C++ ShardChunkManagerPtr::getVersion方法的具体用法?C++ ShardChunkManagerPtr::getVersion怎么用?C++ ShardChunkManagerPtr::getVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShardChunkManagerPtr
的用法示例。
在下文中一共展示了ShardChunkManagerPtr::getVersion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getVersion
const ConfigVersion ShardingState::getVersion( const string& ns ) const {
scoped_lock lk(_mutex);
ChunkManagersMap::const_iterator it = _chunks.find( ns );
if ( it != _chunks.end() ) {
ShardChunkManagerPtr p = it->second;
return p->getVersion();
} else {
return 0;
}
}
示例2: hasVersion
bool ShardingState::hasVersion( const string& ns , ConfigVersion& version ) {
scoped_lock lk(_mutex);
ChunkManagersMap::const_iterator it = _chunks.find(ns);
if ( it == _chunks.end() )
return false;
ShardChunkManagerPtr p = it->second;
version = p->getVersion();
return true;
}
示例3: appendInfo
void ShardingState::appendInfo( BSONObjBuilder& b ) {
b.appendBool( "enabled" , _enabled );
if ( ! _enabled )
return;
b.append( "configServer" , _configServer );
b.append( "shardName" , _shardName );
b.append( "shardHost" , _shardHost );
{
BSONObjBuilder bb( b.subobjStart( "versions" ) );
scoped_lock lk(_mutex);
for ( ChunkManagersMap::iterator it = _chunks.begin(); it != _chunks.end(); ++it ) {
ShardChunkManagerPtr p = it->second;
bb.appendTimestamp( it->first , p->getVersion() );
}
bb.done();
}
}
示例4: getShardChunkManager
ShardChunkManagerPtr ShardingState::getShardChunkManager( const string& ns ){
ConfigVersion version;
{
// check cache
scoped_lock lk( _mutex );
NSVersionMap::const_iterator it = _versions.find( ns );
if ( it == _versions.end() ) {
return ShardChunkManagerPtr();
}
version = it->second;
// TODO SERVER-1849 pending drop work
// the manager should use the cached version only if the versions match exactly
ShardChunkManagerPtr p = _chunks[ns];
if ( p && p->getVersion() >= version ){
// our cached version is good, so just return
return p;
}
}
// load the chunk information for this shard from the config database
// a reminder: ShardChunkManager may throw on construction
const string c = (_configServer == _shardHost) ? "" /* local */ : _configServer;
ShardChunkManagerPtr p( new ShardChunkManager( c , ns , _shardName ) );
// TODO SERVER-1849 verify that the manager's version is exactly the one requested
// If not, do update _chunks, but fail the request.
{
scoped_lock lk( _mutex );
_chunks[ns] = p;
}
return p;
}