Example #1
0
 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 );
 }
Example #2
0
 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);
 }
Example #3
0
 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 );
 }
Example #4
0
    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;
    }
Example #5
0
    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;
    }
Example #6
0
 void DBConnectionPool::release(const string& host, DBClientBase *c) {
     scoped_lock L(_mutex);
     _pools[PoolKey(host,c->getSoTimeout())].done(this,c);
 }
Example #7
0
 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 );
 }