void ObjectDataIStream::addDataPacket( Command& command )
{
    LB_TS_THREAD( _thread );
    LBASSERT( !isReady( ));

    const ObjectDataPacket* packet = command.get< ObjectDataPacket >();
#ifndef NDEBUG
    if( _commands.empty( ))
    {
        LBASSERTINFO( packet->sequence == 0, packet );
    }
    else
    {
        const ObjectDataPacket* previous = 
            _commands.back()->get< ObjectDataPacket >();
        LBASSERTINFO( packet->sequence == previous->sequence+1, 
                      packet->sequence << ", " << previous->sequence );
        LBASSERT( packet->version == previous->version );
    }
#endif

    command.retain();
    _commands.push_back( &command );
    if( packet->last )
        _setReady();
}
void ObjectDataIStream::addDataCommand( ObjectDataICommand command )
{
    LB_TS_THREAD( _thread );
    LBASSERT( !isReady( ));

#ifndef NDEBUG
    const uint128_t& version = command.getVersion();
    const uint32_t sequence = command.getSequence();

    if( _commands.empty( ))
    {
        LBASSERTINFO( sequence == 0, sequence << " in " << command );
    }
    else
    {
        ObjectDataICommand previous( _commands.back() );
        const uint128_t& previousVersion = previous.getVersion();
        const uint32_t previousSequence = previous.getSequence();
        LBASSERTINFO( sequence == previousSequence+1,
                      sequence << ", " << previousSequence );
        LBASSERT( version == previousVersion );
    }
#endif

    _commands.push_back( command );
    if( command.isLast( ))
        _setReady();
}
uint128_t VersionedSlaveCM::sync( const uint128_t& v )
{
#if 0
    LBLOG( LOG_OBJECTS ) << "sync to v" << v << ", id " << _object->getID()
                         << "." << _object->getInstanceID() << std::endl;
#endif
    if( _version == v )
        return _version;

    if( v == VERSION_HEAD )
    {
        _syncToHead();
        return _version;
    }

    const uint128_t version = ( v == VERSION_NEXT ) ? _version + 1 : v;
    LBASSERTINFO( version.high() == 0, "Not a master version: " << version )
    LBASSERTINFO( _version <= version,
                  "can't sync to older version of object " << 
                  lunchbox::className( _object ) << " " << _object->getID() <<
                  " (" << _version << ", " << version <<")" );

    while( _version < version )
        _unpackOneVersion( _queuedVersions.pop( ));

    LocalNodePtr node = _object->getLocalNode();
    if( node.isValid( ))
        node->flushCommands();

    return _version;
}
void VersionedSlaveCM::_unpackOneVersion( ObjectDataIStream* is )
{
    LBASSERT( is );
    LBASSERTINFO( _version == is->getVersion() - 1, "Expected version " 
                  << _version + 1 << ", got " << is->getVersion() << " for "
                  << *_object );

    if( is->hasInstanceData( ))
        _object->applyInstanceData( *is );
    else
        _object->unpack( *is );

    _version = is->getVersion();
    _sendAck();

    LBASSERT( _version != VERSION_INVALID );
    LBASSERT( _version != VERSION_NONE );
    LBASSERTINFO( is->getRemainingBufferSize()==0 && is->nRemainingBuffers()==0,
                  "Object " << typeid( *_object ).name() <<
                  " did not unpack all data" );

#if 0
    LBLOG( LOG_OBJECTS ) << "applied v" << _version << ", id "
                         << _object->getID() << "." << _object->getInstanceID()
                         << std::endl;
#endif
    _releaseStream( is );
}
Beispiel #5
0
void FullMasterCM::_checkConsistency() const
{
#ifndef NDEBUG
    LBASSERT( !_instanceDatas.empty( ));
    LBASSERT( _object->isAttached() );

    if( _version == VERSION_NONE )
        return;

    uint128_t version = _version;
    for( InstanceDataDeque::const_reverse_iterator i = _instanceDatas.rbegin();
         i != _instanceDatas.rend(); ++i )
    {
        const InstanceData* data = *i;
        LBASSERT( data->os.getVersion() != VERSION_NONE );
        LBASSERTINFO( data->os.getVersion() == version,
                      data->os.getVersion() << " != " << version );
        if( data != _instanceDatas.front( ))
        {
            LBASSERTINFO( data->commitCount + _nVersions >= _commitCount,
                          data->commitCount << ", " << _commitCount << " [" <<
                          _nVersions << "]" );
        }
        --version;
    }
#endif
}
Beispiel #6
0
uint32_t ObjectStore::mapNB( Object* object, const uint128_t& id,
                             const uint128_t& version, NodePtr master )
{
    LB_TS_NOT_THREAD( _receiverThread );
    LBLOG( LOG_OBJECTS )
        << "Mapping " << lunchbox::className( object ) << " to id " << id
        << " version " << version << std::endl;
    LBASSERT( object );
    LBASSERTINFO( id.isUUID(), id );

    if( !master )
        master = _localNode->connectObjectMaster( id );

    if( !master || !master->isReachable( ))
    {
        LBWARN << "Mapping of object " << id << " failed, invalid master node"
               << std::endl;
        return LB_UNDEFINED_UINT32;
    }

    if( !object || !id.isUUID( ))
    {
        LBWARN << "Invalid object " << object << " or id " << id << std::endl;
        return LB_UNDEFINED_UINT32;
    }

    const bool isAttached = object->isAttached();
    const bool isMaster = object->isMaster();
    LBASSERTINFO( !isAttached, *object );
    LBASSERT( !isMaster ) ;
    if( isAttached || isMaster )
    {
        LBWARN << "Invalid object state: attached " << isAttached << " master "
               << isMaster << std::endl;
        return LB_UNDEFINED_UINT32;
    }

    const uint32_t request = _localNode->registerRequest( object );
    uint128_t minCachedVersion = VERSION_HEAD;
    uint128_t maxCachedVersion = VERSION_NONE;
    uint32_t masterInstanceID = 0;
    const bool useCache = _checkInstanceCache( id, minCachedVersion,
                                               maxCachedVersion,
                                               masterInstanceID );
    object->notifyAttach();
    master->send( CMD_NODE_MAP_OBJECT )
        << version << minCachedVersion << maxCachedVersion << id
        << object->getMaxVersions() << request << _genNextID( _instanceIDs )
        << masterInstanceID << useCache;
    return request;
}
Beispiel #7
0
BufferPtr BufferCache::alloc( const uint64_t size )
{
    LB_TS_SCOPED( _thread );
    LBASSERTINFO( size >= COMMAND_ALLOCSIZE, size );
    LBASSERTINFO( size < LB_BIT48,
                  "Out-of-sync network stream: buffer size " << size << "?" );

    BufferPtr buffer = _impl->newBuffer();
    LBASSERT( buffer->getRefCount() == 1 );

    buffer->reserve( size );
    buffer->resize( 0 );
    return buffer;
}
Beispiel #8
0
Referenced::~Referenced()
{
    LBASSERT( !_hasBeenDeleted );
    _hasBeenDeleted = true;
    LBASSERTINFO( _refCount == 0,
        "Deleting object with ref count " << _refCount );
}
Beispiel #9
0
uint128_t& uint128_t::operator = ( const std::string& from )
{
    if( from.empty( ))
    {
        _high = 0;
        _low = 0;
        return *this;
    }

    char* next = 0;
    _high = ::strtoull( from.c_str(), &next, 16 );
    LBASSERT( next != from.c_str( ));

    if( *next == '\0' ) // short representation, high was 0
    {
        _low = _high;
        _high = 0;
    }
    else
    {
        if( strncmp( next, "\\058" /* utf-8 ':' */, 4 ) == 0 )
            next += 4;
        else
        {
            LBASSERTINFO( *next == ':', from << ", " << next );
            ++next;
        }
        _low = ::strtoull( next, 0, 16 );
    }
    return *this;
}
Beispiel #10
0
bool DataIStreamQueue::addDataPacket( const uint128_t& key, Command& command )
{
    LB_TS_THREAD( _thread );
    LBASSERTINFO( _pending.size() < 100, "More than 100 pending commits");

    ObjectDataIStream* istream = 0;
    PendingStreams::iterator i = _pending.find( key );
    if( i == _pending.end( ))
        istream = _iStreamCache.alloc();
    else
        istream = i->second;

    istream->addDataPacket( command );
    if( istream->isReady( ))
    {
        if( i != _pending.end( ))
            _pending.erase( i );

        _queued.push( QueuedStream( key, istream ));
        //LBLOG( LOG_OBJECTS ) << "Queued commit " << key << std::endl;
        return true;
    }

    if( i == _pending.end( ))
    {
        _pending[ key ] = istream;
        //LBLOG( LOG_OBJECTS ) << "New incomplete commit " << key << std::endl;
        return false;
    }

    //LBLOG(LOG_OBJECTS) << "Add data to incomplete commit " << key <<std::endl;
    return false;
}
Beispiel #11
0
bool DataIStreamQueue::addDataCommand(const uint128_t& key, ICommand& command)
{
    LB_TS_THREAD(_thread);
    LBASSERTINFO(_pending.size() < 100, "More than 100 pending commits");

    ObjectDataIStream* is = 0;
    PendingStreams::iterator i = _pending.find(key);
    if (i == _pending.end())
        is = _iStreamCache.alloc();
    else
        is = i->second;

    is->addDataCommand(command);
    if (is->isReady())
    {
        if (i != _pending.end())
            _pending.erase(i);

        _queued.push(QueuedStream(key, is));
        return true;
    }

    if (i == _pending.end())
    {
        _pending[key] = is;
        return false;
    }

    return false;
}
Beispiel #12
0
void FrameData::setVersion( const uint64_t version )
{
    LBASSERTINFO( _impl->version <= version, _impl->version << " > "
                                                            << version );
    _impl->version = version;
    LBLOG( LOG_ASSEMBLY ) << "New v" << version << std::endl;
}
void MonitorEqualizer::_updateZoomAndOffset()
{
    const Compound* compound( getCompound( ));
    const PixelViewport& pvp( compound->getInheritPixelViewport( ));

    const Frames& inputFrames( compound->getInputFrames( ));
    const size_t size( inputFrames.size( ));
    LBASSERTINFO( size == _outputFrames.size(),
                  size << " != " << _outputFrames.size( ));
    LBASSERT( size == _viewports.size( ));

    for( size_t i = 0; i < size; ++i )
    {
        Frame* frame = inputFrames[ i ];
        Frame* outputFrame = _outputFrames[ i ];
        if( !outputFrame )
            continue;

        const Compound* srcCompound = outputFrame->getCompound();
        const Viewport& viewport = _viewports[ i ];

        // compute and apply input frame offset
        const int32_t offsetX = int32_t( float( pvp.w ) * viewport.x );
        const int32_t offsetY = int32_t( float( pvp.h ) * viewport.y );
        frame->setNativeOffset( Vector2i( offsetX, offsetY ));

        // compute and apply output frame zoom
        const int32_t width   = int32_t( float( pvp.w ) * viewport.w );
        const int32_t height  = int32_t( float( pvp.h ) * viewport.h ) ;
        const PixelViewport& srcPVP( srcCompound->getInheritPixelViewport( ));
        const Zoom zoom( float( width ) / float( srcPVP.w ),
                         float( height ) / float( srcPVP.h ));
        outputFrame->setNativeZoom( zoom );
    }
}
Beispiel #14
0
void ROITracker::updateDelay( const PixelViewports& pvps,
                              const uint8_t* ticket )
{
    LBASSERT( _needsUpdate );
    LBASSERTINFO( ticket == _ticket, "Wrong ticket" );

    if( ticket != _ticket )
    {
        LBERROR << "Wrong ticket" << std::endl;
        return;
    }

    uint32_t totalAreaFound = 0;
    for( uint32_t i = 0; i < pvps.size(); i++ )
        totalAreaFound += pvps[ i ].getArea();

    Area& area = (*_curFrame)[ _lastStage ].areas.back();
    if( totalAreaFound < area.pvp.getArea()*4/5 )
    {
        // ROI cutted enough, reset failure statistics
        area.lastSkip = 0;
    }else
    {
        // disable ROI for next frames, if it was failing before, 
        // increase number of frames to skip
        area.lastSkip = LB_MIN( area.lastSkip*2 + 1, 64 );
        area.skip     = area.lastSkip;
    }
    _needsUpdate = false;
}
Beispiel #15
0
uint128_t VersionedMasterCM::sync( const uint128_t& inVersion )
{
    LBASSERTINFO( inVersion.high() != 0 || inVersion == VERSION_NEXT ||
                  inVersion == VERSION_HEAD, inVersion );
#if 0
    LBLOG( LOG_OBJECTS ) << "sync to v" << inVersion << ", id "
                         << _object->getID() << "." << _object->getInstanceID()
                         << std::endl;
#endif

    if( inVersion == VERSION_NEXT )
        return _apply( _slaveCommits.pop( ));

    if( inVersion == VERSION_HEAD )
    {
        uint128_t version = VERSION_NONE;
        for( ObjectDataIStream* is = _slaveCommits.tryPop(); is;
                is = _slaveCommits.tryPop( ))
        {
            version = _apply( is );
        }
        return version;
    }
    // else apply only concrete slave commit

    return _apply( _slaveCommits.pull( inVersion ));
}
Beispiel #16
0
bool Node::removeConnectionDescription( ConnectionDescriptionPtr cd )
{
    LBASSERTINFO( isClosed(), *this );
    if( !isClosed( ))
        return false;
    return _removeConnectionDescription( cd );
}
void LoadEqualizer::_assign( Compound* compound, const Viewport& vp,
                             const Range& range )
{
    LBASSERTINFO( vp == Viewport::FULL || range == Range::ALL,
                  "Mixed 2D/DB load-balancing not implemented" );

    compound->setViewport( vp );
    compound->setRange( range );
    LBLOG( LOG_LB2 ) << compound->getChannel()->getName() << " set " << vp
                     << ", " << range << std::endl;

    if( getDamping() >= 1.f )
        return;

    // save data for later use
    Data data;
    data.vp      = vp;
    data.range   = range;
    data.channel = compound->getChannel();
    data.taskID  = compound->getTaskID();

    const Compound* destCompound = getCompound();
    if( destCompound->getChannel() == compound->getChannel( ))
        data.destTaskID  = destCompound->getTaskID();

    LBASSERT( data.taskID > 0 );

    if( !vp.hasArea() || !range.hasData( )) // will not render
        data.time = 0;

    LBFrameData& frameData = _history.back();
    LBDatas& items = frameData.second;

    items.push_back( data );
}
Beispiel #18
0
bool Node::_cmdFrameStart( co::Command& command )
{
    LB_TS_THREAD( _nodeThread );
    const NodeFrameStartPacket* packet = 
        command.get<NodeFrameStartPacket>();
    LBVERB << "handle node frame start " << packet << std::endl;

    const uint32_t frameNumber = packet->frameNumber;
    LBASSERT( _currentFrame == frameNumber-1 );

    LBLOG( LOG_TASKS ) << "----- Begin Frame ----- " << frameNumber
                       << std::endl;

    Config* config = getConfig();
    
    if( packet->configVersion != co::VERSION_INVALID )
        config->sync( packet->configVersion );
    sync( packet->version );

    config->_frameStart();
    frameStart( packet->frameID, frameNumber );

    LBASSERTINFO( _currentFrame >= frameNumber, 
                  "Node::frameStart() did not start frame " << frameNumber );
    return true;
}
Beispiel #19
0
bool Node::_cmdFrameStart( co::ICommand& cmd )
{
    LB_TS_THREAD( _nodeThread );

    co::ObjectICommand command( cmd );
    const uint128_t& version = command.read< uint128_t >();
    const uint128_t& configVersion = command.read< uint128_t >();
    const uint128_t& frameID = command.read< uint128_t >();
    const uint32_t frameNumber = command.read< uint32_t >();

    LBVERB << "handle node frame start " << command << " frame " << frameNumber
           << " id " << frameID << std::endl;

    LBASSERT( _impl->currentFrame == frameNumber-1 );

    LBLOG( LOG_TASKS ) << "----- Begin Frame ----- " << frameNumber
                       << std::endl;

    Config* config = getConfig();

    if( configVersion != co::VERSION_INVALID )
        config->sync( configVersion );
    sync( version );

    config->_frameStart();
    frameStart( frameID, frameNumber );

    LBASSERTINFO( _impl->currentFrame >= frameNumber,
                  "Node::frameStart() did not start frame " << frameNumber );
    return true;
}
Beispiel #20
0
void ObjectStore::_attach( Object* object, const uint128_t& id,
                           const uint32_t inInstanceID )
{
    LBASSERT( object );
    LB_TS_THREAD( _receiverThread );

    uint32_t instanceID = inInstanceID;
    if( inInstanceID == CO_INSTANCE_INVALID )
        instanceID = _genNextID( _instanceIDs );

    object->attach( id, instanceID );

    {
        lunchbox::ScopedFastWrite mutex( _objects );
        Objects& objects = _objects.data[ id ];
        LBASSERTINFO( !object->isMaster() || objects.empty(),
                      "Attaching master " << *object << ", " <<
                      objects.size() << " attached objects with same ID, " <<
                      "first is " << ( objects[0]->isMaster() ? "master " :
                                       "slave " ) << *objects[0] );
        objects.push_back( object );
    }

    _localNode->flushCommands(); // redispatch pending commands

    LBLOG( LOG_OBJECTS ) << "attached " << *object << " @"
                         << static_cast< void* >( object ) << std::endl;
}
Beispiel #21
0
    void* _mapFile(const size_t size_)
    {
        if (size_ > 0 && ::ftruncate(_map, size_) != 0)
        {
            LBINFO << "Can't resize file: " << sysError << std::endl;
            return nullptr;
        }

        // retrieve file information
        struct stat status;
        ::fstat(_map, &status);

        // create memory mapped file
        size = status.st_size;
        LBASSERTINFO(size_ == 0 || size_ == size, size_ << " != " << size);

        const int mapFlags = size_ ? PROT_READ | PROT_WRITE : PROT_READ;
        ptr = ::mmap(0, size, mapFlags, MAP_SHARED, _map, 0);
        if (ptr == MAP_FAILED)
        {
            ::close(_map);
            ptr = nullptr;
            size = 0;
            _map = 0;
        }
        return ptr;
    }
bool CompartmentReportHDF5::writeCompartments( const uint32_t gid,
                                               const uint16_ts& counts )
{
    lunchbox::ScopedWrite mutex( detail::_hdf5Lock );

    try
    {
        const size_t compCount = std::accumulate( counts.begin(),
                                                  counts.end(), 0 );
        LBASSERT( !counts.empty( ));
        LBASSERTINFO( compCount > 0, gid );
        H5::DataSet dataset = _createDataset( gid, compCount );

        const size_t sections = counts.size();
        LBASSERT( sections > 0 );
        dataset.openAttribute( 1 ).write( H5::PredType::NATIVE_INT, &sections );

//        dataset.openAttribute( 2 ).write( H5::PredType::NATIVE_INT, &somas );
//        dataset.openAttribute( 3 ).write( H5::PredType::NATIVE_INT, &axons );
//        dataset.openAttribute( 4 ).write( H5::PredType::NATIVE_INT, &basals );
//        dataset.openAttribute( 5 ).write( H5::PredType::NATIVE_INT, &apics );

        boost::scoped_array< float > mapping( new float[compCount] );
        size_t i = 0;
        for( size_t j = 0; j < counts.size(); ++j )
            for( size_t k = 0; k < counts[j]; ++k )
                mapping[i++] = j;

        dataset.write( mapping.get(), H5::PredType::NATIVE_FLOAT );
        return true;
    }
    CATCH_HDF5ERRORS
    return false;
}
Beispiel #23
0
void Node::addConnectionDescription( ConnectionDescriptionPtr cd )
{
    LBASSERTINFO( isClosed(), *this );
    if( !isClosed( ))
        return;
    _addConnectionDescription( cd );
}
/*  Begin kd-tree setup, go through full range starting with x axis.  */
void VertexBufferRoot::setupTree( VertexData& data )
{
    // data is VertexData, _data is VertexBufferData
    _data.clear();

    const Axis axis = data.getLongestAxis( 0, data.triangles.size() );

    VertexBufferNode::setupTree( data, 0, data.triangles.size(), 
                                 axis, 0, _data );
    VertexBufferNode::updateBoundingSphere();
    VertexBufferNode::updateRange();

#if 0
    // re-test all points to be in the bounding sphere
    Vertex center( _boundingSphere.array );
    float  radius        = _boundingSphere.w();
    float  radiusSquared =  radius * radius;
    for( size_t offset = 0; offset < _data.vertices.size(); ++offset )
    {
        const Vertex& vertex = _data.vertices[ offset ];
        
        const Vertex centerToPoint   = vertex - center;
        const float  distanceSquared = centerToPoint.squared_length();
        LBASSERTINFO( distanceSquared <= radiusSquared,
                      distanceSquared << " > " << radiusSquared );
    }
#endif
}
Beispiel #25
0
int main( int argc, char** argv )
{
    // 1. Equalizer initialization
    NodeFactory nodeFactory;
    eqPly::initErrors();

    // 2. parse arguments
    eqPly::LocalInitData initData;
    initData.parseArguments( argc, argv );

#ifdef EQUALIZER_USE_QT5WIDGETS
    QApplication* app = 0;
    if( initData.getWindowSystem() == "Qt" )
    {
#  ifdef __linux__
        ::XInitThreads();
#  endif
        app = new QApplication( argc, argv );
    }
#endif

    if( !eq::init( argc, argv, &nodeFactory ))
    {
        LBERROR << "Equalizer init failed" << std::endl;
        eq::exit();
        return EXIT_FAILURE;
    }

    // 3. initialization of local client node
    lunchbox::RefPtr< eqPly::EqPly > client = new eqPly::EqPly( initData );
#ifdef EQUALIZER_USE_QT5WIDGETS
    // no working multi GPU setup for Qt yet...
    if( initData.getWindowSystem() == "Qt" )
        client->addActiveLayout( "Simple" );
#endif
    if( !client->initLocal( argc, argv ))
    {
        LBERROR << "Can't init client" << std::endl;
        eq::exit();
        return EXIT_FAILURE;
    }

    // 4. run client
    const int ret = client->run();

    // 5. cleanup and exit
    client->exitLocal();

    LBASSERTINFO( client->getRefCount() == 1, client );
    client = 0;

#ifdef EQUALIZER_USE_QT5WIDGETS
    delete app;
#endif

    eq::exit(); // cppcheck-suppress unreachableCode
    eqPly::exitErrors();
    return ret;
}
Beispiel #26
0
    ~PixelBufferObject()
        {
            LBASSERTINFO( !isInitialized(), (void*)this << backtrace );
            if( isInitialized( ))
                LBWARN << "PBO was not freed" << std::endl;

            delete lock_;
        }
Beispiel #27
0
void Connection::_setDescription( ConnectionDescriptionPtr description )
{
    LBASSERT( description.isValid( ));
    LBASSERTINFO( _impl->description->type == description->type,
                  "Wrong connection type in description" );
    _impl->description = description;
    LBASSERT( description->bandwidth > 0 );
}
Beispiel #28
0
uint32_t ObjectStore::_startSync( Object* object, NodePtr master,
                                  const uint128_t& id,
                                  const uint32_t instanceID )
{
    LB_TS_NOT_THREAD( _receiverThread );
    LBLOG( LOG_OBJECTS )
            << "Syncing " << lunchbox::className( object ) << " with id " << id
            << std::endl;
    LBASSERT( object );
    LBASSERTINFO( id.isUUID(), id );

    if( !object || !id.isUUID( ))
    {
        LBWARN << "Invalid object " << object << " or id " << id << std::endl;
        return LB_UNDEFINED_UINT32;
    }

    if( !master )
        master = _localNode->connectObjectMaster( id );

    if( !master || !master->isReachable( ))
    {
        LBWARN << "Mapping of object " << id << " failed, invalid master node"
               << std::endl;
        return LB_UNDEFINED_UINT32;
    }

    const uint32_t request =
        _localNode->registerRequest( new ObjectDataIStream );
    uint128_t minCachedVersion = VERSION_HEAD;
    uint128_t maxCachedVersion = VERSION_NONE;
    uint32_t cacheInstanceID = 0;

    bool useCache = _checkInstanceCache( id, minCachedVersion, maxCachedVersion,
                                         cacheInstanceID );
    if( useCache )
    {
        switch( instanceID )
        {
        case CO_INSTANCE_ALL:
            break;
        default:
            if( instanceID == cacheInstanceID )
                break;

            useCache = false;
            LBCHECK( _instanceCache->release( id, 1 ));
            break;
        }
    }

    // Use stream expected by MasterCMCommand
    master->send( CMD_NODE_SYNC_OBJECT )
            << VERSION_NEWEST << minCachedVersion << maxCachedVersion << id
            << uint64_t(0) /* maxVersions */ << request << instanceID
            << cacheInstanceID << useCache;
    return request;
}
Beispiel #29
0
void VersionedSlaveCM::applyMapData( const uint128_t& version )
{
    while( true )
    {
        ObjectDataIStream* is = _queuedVersions.pop();
        if( is->getVersion() == version )
        {
            LBASSERTINFO( is->hasInstanceData(), *_object );

            if( is->hasData( )) // not VERSION_NONE
                _object->applyInstanceData( *is );
            _version = is->getVersion();

            LBASSERT( _version != VERSION_INVALID );
//oleg
/*            LBASSERTINFO( !is->hasData(),
                          lunchbox::className( _object ) <<
                          " did not unpack all data, " <<
                          is->getRemainingBufferSize() << " bytes, " <<
                          is->nRemainingBuffers() << " buffer(s)" );
*/
            _releaseStream( is );
#if 0
            LBLOG( LOG_OBJECTS ) << "Mapped initial data of " << _object
                                 << std::endl;
#endif
            return;
        }
        else
        {
            // Found the following case:
            // - p1, t1 calls commit
            // - p1, t2 calls mapObject
            // - p1, cmd commits new version
            // - p1, cmd subscribes object
            // - p1, rcv attaches object
            // - p1, cmd receives commit data
            // -> newly attached object recv new commit data before map data,
            //    ignore it
            LBASSERTINFO( is->getVersion() > version,
                          is->getVersion() << " <= " << version );
            _releaseStream( is );
        }
    }
}
Beispiel #30
0
void releaseConfig( Config* config )
{
    if( !config )
        return;

    ServerPtr server = config->getServer();
    LBASSERT( server.isValid( ));
    server->releaseConfig( config );

    ClientPtr client = server->getClient();
    LBASSERT( client.isValid( ));

    client->disconnectServer( server );
    client->exitLocal();

    LBASSERTINFO( client->getRefCount() == 1, client->getRefCount( ));
    LBASSERTINFO( server->getRefCount() == 1, server->getRefCount( ));
}