コード例 #1
0
void PipelineComposer::open()
{
    setShort(true);

    // create server cross connection
    _clusterWindow->getNetwork()->connectAllGroupToPoint(clusterId(),
            "StreamSock");
    // do not buffer any data
    for(UInt32 i=0 ; i <= serverCount() ; ++i)
        clusterWindow()->getNetwork()->getConnection(i)->forceDirectIO();
    if(!_isClient)
    {
        // create barrier
        _lock = Lock::get("PipelineComposer");
        // create barrier
        _barrier = Barrier::get("PipelineComposer");
        _frameEndBarrier = Barrier::get("PipelineComposerFrameEnd");
        // create writer thread
        _writer = BaseThread::get("PipelineComposer");
        // start writer thread
        _writer->runFunction( writeProc, this );
    }
    if(!_isClient && getPipelined())
    {
        _composeBarrier = Barrier::get("PipelineComposerCompose");
//        _composer = BaseThread::get("PipelineComposerCompose");
        _composer = dynamic_cast<Thread *>(ThreadManager::the()->getThread(NULL));
        _composer->runFunction( composeProc,0, this );
    }

#ifdef USE_NV_OCCLUSION
    glGenOcclusionQueriesNV(1, &_occlusionQuery);
#endif
}
コード例 #2
0
void BinarySwapComposer::open()
{
    // determine usable servers
    if(osgispower2(serverCount()))
        _usableServers = serverCount();
    else
        _usableServers = osgnextpower2(serverCount()) / 2;

//    _usableServers = 1;

    // create server cross connection
    _clusterWindow->getNetwork()->connectAllPointToPoint(clusterId(),
                                                         "StreamSock");
    // do not buffer any data
    for(UInt32 i=0 ; i <= serverCount() ; ++i)
        clusterWindow()->getNetwork()->getConnection(i)->forceDirectIO();

/*
    // create barrier
    _barrier = Barrier::get(NULL);
    // create writer thread
    _writer = BaseThread::get(NULL);
*/

    // read whole buffer
    if(!_isClient && clusterId() < _usableServers)
    {
        // create barrier
        _barrier = Barrier::get(NULL);
        // create writer thread
        _writer = BaseThread::get(NULL);
        // start writer thread
        _writer->runFunction( writeProc, this );
    }
    else
    {
        _writer = NULL;
    }
}
コード例 #3
0
void ShardingInitializationMongoD::initializeFromShardIdentity(
    OperationContext* opCtx, const ShardIdentityType& shardIdentity) {
    invariant(serverGlobalParams.clusterRole == ClusterRole::ShardServer);
    invariant(opCtx->lockState()->isLocked());

    uassertStatusOKWithContext(
        shardIdentity.validate(),
        "Invalid shard identity document found when initializing sharding state");

    log() << "initializing sharding state with: " << shardIdentity;

    const auto& configSvrConnStr = shardIdentity.getConfigsvrConnectionString();

    auto const shardingState = ShardingState::get(opCtx);
    auto const shardRegistry = Grid::get(opCtx)->shardRegistry();

    stdx::unique_lock<stdx::mutex> ul(_initSynchronizationMutex);

    if (shardingState->enabled()) {
        uassert(40371, "", shardingState->shardId() == shardIdentity.getShardName());
        uassert(40372, "", shardingState->clusterId() == shardIdentity.getClusterId());

        auto prevConfigsvrConnStr = shardRegistry->getConfigServerConnectionString();
        uassert(40373, "", prevConfigsvrConnStr.type() == ConnectionString::SET);
        uassert(40374, "", prevConfigsvrConnStr.getSetName() == configSvrConnStr.getSetName());

        return;
    }

    auto initializationStatus = shardingState->initializationStatus();
    uassert(ErrorCodes::ManualInterventionRequired,
            str::stream() << "Server's sharding metadata manager failed to initialize and will "
                             "remain in this state until the instance is manually reset"
                          << causedBy(*initializationStatus),
            !initializationStatus);

    try {
        _initFunc(opCtx, shardIdentity, generateDistLockProcessId(opCtx));
        shardingState->setInitialized(shardIdentity.getShardName().toString(),
                                      shardIdentity.getClusterId());
    } catch (const DBException& ex) {
        shardingState->setInitialized(ex.toStatus());
    }
}
コード例 #4
0
void ParallelComposer::open(void)
{
#ifdef OSG_WITH_PARALLEL
    if(getPcLibPath() != "")
    {
        pcSysInitialize(getPcLibPath().c_str(), 123458);
    }
    else
    {
        char *pc = getenv("PCLIB_PATH");
        if(pc!= NULL)
            pcSysInitialize(pc, 123458);
        else
            pcSysInitialize(".", 123458);
    }
    
    // Initialize buffers
    _bufColor	   = NULL;
    _bufDepth	   = NULL;
    _bufRet 	   = NULL;
    _createContext = true;
    
    // determine usable servers
    _usableServers = serverCount();

    // create server cross connection
    _clusterWindow->getNetwork()->connectAllPointToPoint(clusterId(),
                                                         "StreamSock");
    // do not buffer any data
    for(UInt32 i=0 ; i <= serverCount() ; ++i)
        clusterWindow()->getNetwork()->getConnection(i)->forceDirectIO();	
    // populate server list from inherited cluster window
    osgGetHostname(_serviceAddr, sizeof(_serviceAddr));

    _serverList = new char*[_usableServers+2];
    _serverList[0]  = _serviceAddr;
    int i = 1;
    for(; i<_usableServers+1; i++)
    {
        _serverList[i] = (char*)clusterWindow()->getServers(i-1).c_str();
    }
    _serverList[i]= NULL;
#endif
}
コード例 #5
0
BSONObj ShardIdentityType::toBSON() const {
    BSONObjBuilder builder;

    builder.append("_id", IdName);

    if (_configsvrConnString) {
        builder << configsvrConnString(_configsvrConnString->toString());
    }

    if (_shardName) {
        builder << shardName(_shardName.get());
    }

    if (_clusterId) {
        builder << clusterId(_clusterId.get());
    }

    return builder.obj();
}
コード例 #6
0
Status ShardIdentityType::validate() const {
    if (!_configsvrConnString) {
        return {ErrorCodes::NoSuchKey,
                str::stream() << "missing " << configsvrConnString() << " field"};
    }

    if (_configsvrConnString->type() != ConnectionString::SET) {
        return {ErrorCodes::UnsupportedFormat,
                str::stream() << "config connection string can only be replica sets, got "
                << ConnectionString::typeToString(_configsvrConnString->type())};
    }

    if (!_shardName || _shardName->empty()) {
        return {ErrorCodes::NoSuchKey, str::stream() << "missing " << shardName() << " field"};
    }

    if (!_clusterId || !_clusterId->isSet()) {
        return {ErrorCodes::NoSuchKey, str::stream() << "missing " << clusterId() << " field"};
    }

    return Status::OK();
}
コード例 #7
0
void BinarySwapComposer::composeViewport(ViewportPtr port)
{
    // setup viewport
    GLint 
        pl=port->getPixelLeft(), 
        pr=port->getPixelRight(),
        pb=port->getPixelBottom(), 
        pt=port->getPixelTop();
    GLint pw=pr-pl+1,ph=pt-pb+1;
    bool full = port->isFullWindow();
    glViewport(pl, pb, pw, ph);
    glScissor(pl, pb, pw, ph);
    if(! full)
        glEnable(GL_SCISSOR_TEST);

    GLboolean depth = glIsEnabled(GL_DEPTH_TEST);
    GLboolean blend = glIsEnabled(GL_BLEND);

    glDisable(GL_DEPTH_TEST);
    glPushMatrix();
    glLoadIdentity();
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(0, port->getPixelWidth(),
            0, port->getPixelHeight(),-1,1);

//    printf("max %x,%x\n",_intDepthMax,_shortDepthMax);

    if(getAlpha())
    {
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    }
    _tilesX = port->getPixelWidth()  / getTileSize() + 1;
    _tilesY = port->getPixelHeight() / getTileSize() + 1;

    _tileBufferSize = getTileSize()*getTileSize()*8+sizeof(TileBuffer);
    _readTile.resize(_tileBufferSize);

    _statistics.bytesIn  = 0;
    _statistics.bytesOut = 0;

    if(isClient())
    {
        if(getShort())
        {
            UInt16 colorDummy;
            UInt32 depthDummy;
            recvFromServers(depthDummy,colorDummy,
                            GL_RGB,
                            GL_UNSIGNED_SHORT_5_6_5,
                            port);
        }
        else
        {
            if(getAlpha())
            {
                UInt32 colorDummy;
                UInt32 depthDummy;
                recvFromServers(depthDummy,colorDummy,
                                GL_RGBA,
                                GL_UNSIGNED_BYTE,
                                port);
            }
            else
            {
                RGBValue colorDummy;
                UInt32   depthDummy;
                recvFromServers(depthDummy,colorDummy,
                                GL_RGB,
                                GL_UNSIGNED_BYTE,
                                port);
            }
        }
        if(getStatistics())
        {
            UInt32      maxIn   = _statistics.bytesIn;
            UInt32      maxOut  = _statistics.bytesOut;
            UInt32      maxIO   = maxIn + maxOut;
            UInt32      sumOut  = _statistics.bytesOut;
            UInt32      missing = _usableServers;
            double      composeTime = 1e32;
            
            Connection *server;
            Statistics  statistics;
            for(UInt32 i=0 ; i<_usableServers ;++i)
            {
                server = clusterWindow()->getNetwork()->getConnection(i);
                server->selectChannel();
                server->get(&statistics,sizeof(Statistics));
                sumOut += statistics.bytesOut;
                if(statistics.composeTime < composeTime)
                    composeTime = statistics.composeTime;
                if(statistics.bytesOut > maxOut)
                    maxOut = statistics.bytesOut;
                if(statistics.bytesIn > maxIn)
                    maxIn = statistics.bytesIn;
                if(statistics.bytesIn + statistics.bytesOut > maxIO)
                    maxIO = statistics.bytesIn + statistics.bytesOut;
                missing--;
            }
            printf("compose Time     : %1.5lf\n",composeTime);
            printf("Transfered bytes : %10d\n",sumOut);
            printf("Max out          : %10d\n",maxOut);
            printf("Max in           : %10d\n",maxIn);
            printf("Max io           : %10d\n",maxIO);
        }
    }
    else
    {
        if(clusterId() < _usableServers)
        {
            _statistics.composeTime = -getSystemTime();
            _tile.resize(_tileBufferSize * _tilesX * _tilesY);
            if(getShort())
            {
                UInt16 colorDummy;
                UInt32 depthDummy=_shortDepthMax;
//                UInt32 depthDummy=_intDepthMax;
                startReader(depthDummy,colorDummy,
//                            GL_UNSIGNED_SHORT,
                            GL_UNSIGNED_INT,
                            GL_RGB,
                            GL_UNSIGNED_SHORT_5_6_5,
                            port);
            }
            else
            {
                if(getAlpha())
                {
                    UInt32 colorDummy;
                    UInt32 depthDummy=_intDepthMax;
                    startReader(depthDummy,colorDummy,
                                GL_UNSIGNED_INT,
                                GL_RGBA,
                                GL_UNSIGNED_BYTE,
                                port);
                }
                else
                {
                    RGBValue colorDummy;
                    UInt32   depthDummy=_intDepthMax;
                    startReader(depthDummy,colorDummy,
                                GL_UNSIGNED_INT,
                                GL_RGB,
                                GL_UNSIGNED_BYTE,
                                port);
                }
            }
            _statistics.composeTime += getSystemTime();
            if(getStatistics())
            {
                Connection *client = clusterWindow()->getNetwork()->getConnection(serverCount());
                client->put(&_statistics,sizeof(Statistics));
                client->flush();
            }
        }
/*
        // max depth value !! find a better way
        glClear(GL_DEPTH_BUFFER_BIT);
        glReadPixels(0, 0, 1, 1, 
                     GL_DEPTH_COMPONENT, GL_UNSIGNED_INT,
                     &_intDepthMax);
        glReadPixels(0, 0, 1, 1, 
                     GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT,
                     &_shortDepthMax);
*/
    }

    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
    glEnable(GL_DEPTH_TEST);

    // reset state
    if(depth && !glIsEnabled(GL_DEPTH_TEST))
        glEnable(GL_DEPTH_TEST);
    if(!blend && glIsEnabled(GL_BLEND))
        glDisable(GL_BLEND);
}
コード例 #8
0
void ParallelComposer::composeViewport(ViewportPtr port)
{
#ifdef OSG_WITH_PARALLEL
    // setup viewport
    GLint 
        pl=port->getPixelLeft(), 
        pr=port->getPixelRight(),
        pb=port->getPixelBottom(), 
        pt=port->getPixelTop();
    if(_wWidth != pr-pl+1 || _wHeight != pt-pb+1)
    {
        _wWidth = pr-pl+1;
        _wHeight= pt-pb+1;
        _createContext = true;
    }
    bool full = port->isFullWindow();
    glViewport(pl, pb, _wWidth, _wHeight);
    glScissor(pl, pb, _wWidth, _wHeight);
    if(! full)
        glEnable(GL_SCISSOR_TEST);

    GLboolean depth = glIsEnabled(GL_DEPTH_TEST);
    GLboolean blend = glIsEnabled(GL_BLEND);

    glDisable(GL_DEPTH_TEST);
    glPushMatrix();
    glLoadIdentity();
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(0, port->getPixelWidth(),
            0, port->getPixelHeight(),-1,1);

    if(_createContext)
    {
        createCtx(port);
        _createContext = false;
    }

    if(getAlpha())
    {
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    }

    if(isClient())
    {
        UInt32 id = beginFrame();
        renderRead();
        endFrame(id);
        drawFrame();
    }
    else
    {
        if(clusterId() < _usableServers)
        {
            UInt32 id = beginFrame();
            renderRead();
            endFrame(id);
            //drawFrame();
        }
    }
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
    glEnable(GL_DEPTH_TEST);

    // reset state
    if(depth && !glIsEnabled(GL_DEPTH_TEST))
        glEnable(GL_DEPTH_TEST);
    if(!blend && glIsEnabled(GL_BLEND))
        glDisable(GL_BLEND);
#endif
}
コード例 #9
0
StatusWith<ShardIdentityType> ShardIdentityType::fromBSON(const BSONObj& source) {
    if (!source.hasField("_id")) {
        return {ErrorCodes::NoSuchKey,
                str::stream() << "missing _id field for shardIdentity document"};
    }

    ShardIdentityType shardIdentity;

    {
        std::string docId;
        Status status = bsonExtractStringField(source, "_id", &docId);
        if (!status.isOK()) {
            return status;
        }

        if (docId != IdName) {
            return {ErrorCodes::FailedToParse,
                    str::stream() << "got _id: " << docId << " instead of " << IdName};
        }
    }

    {
        std::string connString;
        Status status = bsonExtractStringField(source, configsvrConnString(), &connString);
        if (!status.isOK()) {
            return status;
        }

        try {
            // Note: ConnectionString::parse can uassert from HostAndPort constructor.
            auto parsedConfigConnStrStatus = ConnectionString::parse(connString);
            if (!parsedConfigConnStrStatus.isOK()) {
                return parsedConfigConnStrStatus.getStatus();
            }

            auto configSvrConnStr = parsedConfigConnStrStatus.getValue();
            if (configSvrConnStr.type() != ConnectionString::SET) {
                return Status(ErrorCodes::UnsupportedFormat,
                              str::stream()
                              << "config server connection string can only be replica sets: "
                              << configSvrConnStr.toString());
            }

            shardIdentity.setConfigsvrConnString(std::move(configSvrConnStr));
        } catch (const UserException& parseException) {
            return parseException.toStatus();
        }
    }

    {
        std::string name;
        Status status = bsonExtractStringField(source, shardName(), &name);
        if (!status.isOK()) {
            return status;
        }

        shardIdentity.setShardName(name);
    }

    {
        OID oid;
        Status status = bsonExtractOIDField(source, clusterId(), &oid);
        if (!status.isOK()) {
            return status;
        }

        shardIdentity.setClusterId(oid);
    }

    return shardIdentity;
}