DBClientBase* DBConnectionPool::_get(const string& ident , double socketTimeout ) { verify( ! inShutdown() ); scoped_lock L(_mutex); PoolForHost& p = _pools[PoolKey(ident,socketTimeout)]; p.initializeHostName(ident); return p.get( this , socketTimeout ); }
void DBConnectionPool::release(const string& host, DBClientBase *c) { if ( c->isFailed() ) { onDestroy( c ); delete c; return; } scoped_lock L(_mutex); _pools[PoolKey(host,c->getSoTimeout())].done(this,c); }
DBClientBase* DBConnectionPool::_get(const string& ident , double socketTimeout ) { uassert(17382, "Can't use connection pool during shutdown", !inShutdown()); scoped_lock L(_mutex); PoolForHost& p = _pools[PoolKey(ident,socketTimeout)]; p.setMaxPoolSize(_maxPoolSize); p.initializeHostName(ident); return p.get( this , socketTimeout ); }
DBClientBase* DBConnectionPool::_finishCreate( const string& host , double socketTimeout , DBClientBase* conn ) { { scoped_lock L(_mutex); PoolForHost& p = _pools[PoolKey(host,socketTimeout)]; p.createdOne( conn ); } try { onCreate( conn ); onHandedOut( conn ); } catch ( std::exception& e ) { delete conn; throw; } return conn; }
bool DBConnectionPool::isConnectionGood(const string& hostName, DBClientBase* conn) { if (conn == NULL) { return false; } if (conn->isFailed()) { return false; } { scoped_lock sl(_mutex); PoolForHost& pool = _pools[PoolKey(hostName, conn->getSoTimeout())]; if (pool.isBadSocketCreationTime(conn->getSockCreationMicroSec())) { return false; } } return true; }
void DBConnectionPool::release(const string& host, DBClientBase *c) { scoped_lock L(_mutex); _pools[PoolKey(host,c->getSoTimeout())].done(this,c); }
DBClientBase* DBConnectionPool::_get(const string& ident , double socketTimeout ) { assert( ! inShutdown() ); scoped_lock L(_mutex); PoolForHost& p = _pools[PoolKey(ident,socketTimeout)]; return p.get( this , socketTimeout ); }