当前位置: 首页>>代码示例>>C++>>正文


C++ DBConnectionPool::get方法代码示例

本文整理汇总了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.
                }
            }
        }
开发者ID:ANTco,项目名称:mongo,代码行数:33,代码来源:shardconnection.cpp

示例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;
                }
            }
        }
开发者ID:acruikshank,项目名称:mongo,代码行数:28,代码来源:shardconnection.cpp

示例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;
                }
            }
        }
开发者ID:Bamco,项目名称:mongo,代码行数:27,代码来源:shardconnection.cpp

示例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();
        }
开发者ID:ANTco,项目名称:mongo,代码行数:16,代码来源:shardconnection.cpp

示例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 );
        }
开发者ID:humcycles,项目名称:mongo,代码行数:43,代码来源:shardconnection.cpp

示例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();
        }
开发者ID:Bamco,项目名称:mongo,代码行数:22,代码来源:shardconnection.cpp

示例7:

 ScopedDbConnection::ScopedDbConnection(const Shard* shard, double socketTimeout )
     : _host( shard->getConnString() ) , _conn( pool.get(_host, socketTimeout) ), _socketTimeout( socketTimeout ) {
     _setSocketTimeout();
 }
开发者ID:gregstuder,项目名称:mongo,代码行数:4,代码来源:connpool.cpp

示例8:

 ScopedDbConnection::ScopedDbConnection(const Shard* shard )
     : _host( shard->getConnString() ) , _conn( pool.get(_host) ){
 }
开发者ID:chrelad,项目名称:mongo,代码行数:3,代码来源:connpool.cpp


注:本文中的DBConnectionPool::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。