Beispiel #1
0
    bool ReplicaSetMonitor::_checkConnection( DBClientConnection * c , string& maybePrimary , bool verbose ) {
        bool isMaster = false;
        bool changed = false;
        try {
            BSONObj o;
            c->isMaster(isMaster, &o);

            log( ! verbose ) << "ReplicaSetMonitor::_checkConnection: " << c->toString() << ' ' << o << '\n';

            // add other nodes
            string maybePrimary;
            if ( o["hosts"].type() == Array ) {
                if ( o["primary"].type() == String )
                    maybePrimary = o["primary"].String();

                _checkHosts(o["hosts"].Obj(), changed);
            }
            if (o.hasField("passives") && o["passives"].type() == Array) {
                _checkHosts(o["passives"].Obj(), changed);
            }

            _checkStatus(c);
        }
        catch ( std::exception& e ) {
            log( ! verbose ) << "ReplicaSetMonitor::_checkConnection: caught exception " << c->toString() << ' ' << e.what() << endl;
        }

        if ( changed && _hook )
            _hook( this );

        return isMaster;
    }
Beispiel #2
0
    RocksRecordStore::Iterator::Iterator( OperationContext* txn,
                                          const RocksRecordStore* rs,
                                          const CollectionScanParams::Direction& dir,
                                          const DiskLoc& start )
        : _txn( txn ),
          _rs( rs ),
          _dir( dir ),
          // XXX not using a snapshot here
          _iterator( _rs->_db->NewIterator( rs->_readOptions(), rs->_columnFamily ) ) {
        if (start.isNull()) {
            if ( _forward() )
                _iterator->SeekToFirst();
            else
                _iterator->SeekToLast();
        }
        else {
            _iterator->Seek( rs->_makeKey( start ) );

            if ( !_forward() && !_iterator->Valid() )
                _iterator->SeekToLast();
            else if ( !_forward() && _iterator->Valid() &&
                      _makeDiskLoc( _iterator->key() ) != start )
                _iterator->Prev();
        }

        _checkStatus();
    }
Beispiel #3
0
    bool GLProgram::link()
    {
        glLinkProgram(_handle);

        if (_checkStatus(_handle))
        {
            _isLinked = true;
        }
        else
        {
            _isLinked = false;
        }

        return _isLinked;
    }
bool FrameBufferObject::resize( const int32_t width, const int32_t height )
{
    LB_TS_THREAD( _thread );
    LBASSERT( width > 0 && height > 0 );

    LBASSERT( !_colors.empty( ));
    Texture* color = _colors.front();

    if( color->getWidth() == width && color->getHeight() == height && _valid )
       return true;

    for( size_t i = 0; i < _colors.size(); ++i )
        _colors[i]->resize( width, height );

    if ( _depth.isValid( ))
        _depth.resize( width, height );

    return _checkStatus();
}
bool FrameBufferObject::init( const int32_t width, const int32_t height,
                              const GLuint colorFormat,
                              const int32_t depthSize,
                              const int32_t stencilSize )
{
    LB_TS_THREAD( _thread );

    if( _fboID )
    {
        _setError( ERROR_FRAMEBUFFER_INITIALIZED );
        LBWARN << _error << std::endl;
        return false;
    }

    // generate and bind the framebuffer
    glGenFramebuffersEXT( 1, &_fboID );
    glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, _fboID );

    // create and bind textures
    for( unsigned i = 0; i < _colors.size(); ++i )
    {
        _colors[i]->init( colorFormat, width, height );
        _colors[i]->bindToFBO( GL_COLOR_ATTACHMENT0 + i, width, height );
    }
    if( stencilSize > 0 && GLEW_EXT_packed_depth_stencil )
    {
        _depth.init( GL_DEPTH24_STENCIL8, width, height );
        _depth.bindToFBO( GL_DEPTH_STENCIL_ATTACHMENT, width, height ); 
    }
    else if( depthSize > 0 )
    {
        _depth.init( GL_DEPTH_COMPONENT, width, height );
        _depth.bindToFBO( GL_DEPTH_ATTACHMENT, width, height );
    }

    if( _checkStatus( ))
        return true;
    // else

    exit();
    return false;
}
Beispiel #6
0
    bool GLProgram::compileShader(const char* shader, GLenum type, bool isFilePath)
    {
        // Create an OpenGL program if it doesn't exist already
        if (_handle == 0)
        {
            _handle = glCreateProgram();

            if (_handle == 0)
            {
                _log = "nut::GLProgram error: glCreateProgram failed.";
                return false;
            }
        }

        std::string code;

        // Load shader from file or...
        if (isFilePath)
        {
            std::ifstream in(shader, std::ios::in | std::ios::binary);

            // Put all text-file content in a string
            if (in.is_open())
            {
                in.seekg(0, std::ios::end);
                size_t size = in.tellg();
                in.seekg(0, std::ios::beg);
                code.resize(size);
                in.read(&code[0], size);
                in.close();
            }
        }
        // ... the string contains shader code
        else
        {
            code = shader;
        }

        /// 1. Create a shader object

        GLuint shaderHandle = glCreateShader(type);

        if (shaderHandle == 0)
        {
            _log = "nut::GLProgram error: glCreateShader failed.";
            return false;
        }

        /// 2. Load and compile the shader
        
        const GLchar* c = code.c_str();
        glShaderSource(shaderHandle, 1, &c, NULL);

        glCompileShader(shaderHandle);

        if (!_checkStatus(shaderHandle))
        {
            return false;
        }

        /// 3. Attach shader to program

        glAttachShader(_handle, shaderHandle);

        glDeleteShader(shaderHandle);
        
        return true;
    }