本文整理汇总了C++中DBConnectionPool::get方法的典型用法代码示例。如果您正苦于以下问题:C++ DBConnectionPool::get方法的具体用法?C++ DBConnectionPool::get怎么用?C++ DBConnectionPool::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnectionPool
的用法示例。
在下文中一共展示了DBConnectionPool::get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkVersions
void checkVersions( const string& ns ) {
vector<Shard> all;
Shard::getAllShards( all );
// Don't report exceptions here as errors in GetLastError
LastError::Disabled ignoreForGLE(lastError.get(false));
// Now only check top-level shard connections
for ( unsigned i=0; i<all.size(); i++ ) {
Shard& shard = all[i];
try {
string sconnString = shard.getConnString();
Status* s = _getStatus( sconnString );
if( ! s->avail ) {
s->avail = shardConnectionPool.get( sconnString );
s->created++; // After, so failed creation doesn't get counted
}
versionManager.checkShardVersionCB( s->avail, ns, false, 1 );
}
catch ( const DBException& ex ) {
warning() << "problem while initially checking shard versions on" << " "
<< shard.getName() << causedBy( ex ) << endl;
// NOTE: This is only a heuristic, to avoid multiple stale version retries
// across multiple shards, and does not affect correctness.
}
}
}
示例2: checkVersions
void checkVersions( const string& ns ) {
vector<Shard> all;
Shard::getAllShards( all );
// Now only check top-level shard connections
for ( unsigned i=0; i<all.size(); i++ ) {
Shard& shard = all[i];
try {
string sconnString = shard.getConnString();
Status* s = _getStatus( sconnString );
if( ! s->avail ) {
s->avail = shardConnectionPool.get( sconnString );
s->created++; // After, so failed creation doesn't get counted
}
versionManager.checkShardVersionCB( s->avail, ns, false, 1 );
}
catch ( const std::exception& e ) {
warning() << "problem while initially checking shard versions on"
<< " " << shard.getName() << causedBy(e) << endl;
throw;
}
}
}
示例3: checkVersions
void checkVersions( const string& ns ) {
vector<Shard> all;
Shard::getAllShards( all );
// Now only check top-level shard connections
for ( unsigned i=0; i<all.size(); i++ ) {
Shard& shard = all[i];
try {
string sconnString = shard.getConnString();
Status* &s = _hosts[sconnString];
if ( ! s ){
s = new Status();
}
if( ! s->avail )
s->avail = shardConnectionPool.get( sconnString );
versionManager.checkShardVersionCB( s->avail, ns, false, 1 );
} catch(...) {
LOGATMOST(2) << "exception in checkAllVersions shard:" << shard.getName() << endl;
throw;
}
}
}
示例4: get
DBClientBase * get( const string& addr , const string& ns ) {
_check( ns );
Status* s = _getStatus( addr );
auto_ptr<DBClientBase> c; // Handles cleanup if there's an exception thrown
if ( s->avail ) {
c.reset( s->avail );
s->avail = 0;
shardConnectionPool.onHandedOut( c.get() ); // May throw an exception
} else {
c.reset( shardConnectionPool.get( addr ) );
s->created++; // After, so failed creation doesn't get counted
}
return c.release();
}
示例5: get
DBClientBase * get( const string& addr , const string& ns, bool ignoreDirect = false ) {
_check( ns );
// Determine if non-shard conn is RS member for warning
// All shards added to _hosts if not present in _check()
if( ( logLevel >= 1 || ! printedShardConnWarning ) && ! ignoreDirect && _hosts.find( addr ) == _hosts.end() ){
vector<Shard> all;
Shard::getAllShards( all );
bool isRSMember = false;
string parentShard;
for ( unsigned i = 0; i < all.size(); i++ ) {
string connString = all[i].getConnString();
if( connString.find( addr ) != string::npos && connString.find( '/' ) != string::npos ){
isRSMember = true;
parentShard = connString;
break;
}
}
if( isRSMember ){
printedShardConnWarning = true;
warning() << "adding shard sub-connection " << addr << " (parent " << parentShard << ") as sharded, this is safe but unexpected" << endl;
printStackTrace();
}
}
Status* &s = _hosts[addr];
if ( ! s )
s = new Status();
if ( s->avail ) {
DBClientBase* c = s->avail;
s->avail = 0;
shardConnectionPool.onHandedOut( c );
return c;
}
s->created++;
return shardConnectionPool.get( addr );
}
示例6: get
DBClientBase * get( const string& addr , const string& ns ) {
_check( ns );
Status* &s = _hosts[addr];
if ( ! s )
s = new Status();
auto_ptr<DBClientBase> c; // Handles cleanup if there's an exception thrown
if ( s->avail ) {
c.reset( s->avail );
s->avail = 0;
shardConnectionPool.onHandedOut( c.get() ); // May throw an exception
} else {
s->created++;
c.reset( shardConnectionPool.get( addr ) );
}
if ( !noauth ) {
c->setAuthenticationTable( ClientBasic::getCurrent()->getAuthenticationInfo()->
getAuthTable() );
}
return c.release();
}
示例7:
ScopedDbConnection::ScopedDbConnection(const Shard* shard, double socketTimeout )
: _host( shard->getConnString() ) , _conn( pool.get(_host, socketTimeout) ), _socketTimeout( socketTimeout ) {
_setSocketTimeout();
}
示例8:
ScopedDbConnection::ScopedDbConnection(const Shard* shard )
: _host( shard->getConnString() ) , _conn( pool.get(_host) ){
}