Example #1
0
void FullMasterCM::_obsolete()
{
    LBASSERT( !_instanceDatas.empty( ));
    while( _instanceDatas.size() > 1 && _commitCount > _nVersions )
    {
        InstanceData* data = _instanceDatas.front();
        if( data->commitCount >= (_commitCount - _nVersions))
            break;

#ifdef CO_INSTRUMENT
        _bytesBuffered -= data->os.getSaveBuffer().getSize();
        LBINFO << _bytesBuffered << " bytes used" << std::endl;
#endif
#if 0
        LBINFO
            << "Remove v" << data->os.getVersion() << " c" << data->commitCount
            << "@" << _commitCount << "/" << _nVersions << " from "
            << lunchbox::className( _object ) << " " << ObjectVersion( _object )
            << std::endl;
#endif
        _releaseInstanceData( data );
        _instanceDatas.pop_front();
    }
    _checkConsistency();
}
Example #2
0
void ObjectMap::serialize(DataOStream& os, const uint64_t dirtyBits)
{
    lunchbox::ScopedFastWrite mutex(_impl->lock);
    if (dirtyBits == DIRTY_ALL)
    {
        for (MapCIter i = _impl->map.begin(); i != _impl->map.end(); ++i)
            os << i->first << i->second.version << i->second.type;
        os << ObjectVersion();
        return;
    }

    if (dirtyBits & DIRTY_ADDED)
    {
        os << _impl->added;
        for (IDVectorCIter i = _impl->added.begin(); i != _impl->added.end();
             ++i)
        {
            const Entry& entry = _impl->map[*i];
            os << entry.version << entry.type;
        }
    }
    if (dirtyBits & DIRTY_REMOVED)
        os << _impl->removed;
    if (dirtyBits & DIRTY_CHANGED)
        os << _impl->changed;
}
Example #3
0
void ObjectMap::deserialize(DataIStream& is, const uint64_t dirtyBits)
{
    lunchbox::ScopedFastWrite mutex(_impl->lock);
    if (dirtyBits == DIRTY_ALL)
    {
        LBASSERT(_impl->map.empty());

        ObjectVersion ov;
        is >> ov;
        while (ov != ObjectVersion())
        {
            LBASSERT(_impl->map.find(ov.identifier) == _impl->map.end());
            Entry& entry = _impl->map[ov.identifier];
            entry.version = ov.version;
            is >> entry.type >> ov;
        }
        return;
    }
Example #4
0
bool FullMasterCM::_initSlave( const MasterCMCommand& command,
                               const uint128_t& /*replyVersion*/,
                               bool replyUseCache )
{
    _checkConsistency();

    const uint128_t& version = command.getRequestedVersion();
    const uint128_t oldest = _instanceDatas.front()->os.getVersion();
    uint128_t start = (version == VERSION_OLDEST || version < oldest ) ?
                          oldest : version;
    uint128_t end = _version;

#ifndef NDEBUG
    if( version != VERSION_OLDEST && version < start )
        LBINFO << "Mapping version " << start << " instead of requested "
               << version << " for " << lunchbox::className( _object )
               << " " << ObjectVersion( _object->getID(), _version ) << " of "
               << _instanceDatas.size() << "/" << _nVersions << std::endl;
#endif

    const uint128_t& minCachedVersion = command.getMinCachedVersion();
    const uint128_t& maxCachedVersion = command.getMaxCachedVersion();
    const uint128_t replyVersion = start;
    if( replyUseCache )
    {
        if( minCachedVersion <= start && maxCachedVersion >= start )
        {
#ifdef CO_INSTRUMENT_MULTICAST
            _hit += maxCachedVersion + 1 - start;
#endif
            start = maxCachedVersion + 1;
        }
        else if( maxCachedVersion == end )
        {
            end = LB_MAX( start, minCachedVersion - 1 );
#ifdef CO_INSTRUMENT_MULTICAST
            _hit += _version - end;
#endif
        }
        // TODO else cached block in the middle, send head and tail elements
    }

#if 0
    LBLOG( LOG_OBJECTS )
        << *_object << ", instantiate on " << node->getNodeID() << " with v"
        << ((requested == VERSION_OLDEST) ? oldest : requested) << " ("
        << requested << ") sending " << start << ".." << end << " have "
        << _version - _nVersions << ".." << _version << " "
        << _instanceDatas.size() << std::endl;
#endif
    LBASSERT( start >= oldest );

    bool dataSent = false;

    // send all instance datas from start..end
    InstanceDataDeque::iterator i = _instanceDatas.begin();
    while( i != _instanceDatas.end() && (*i)->os.getVersion() < start )
        ++i;

    for( ; i != _instanceDatas.end() && (*i)->os.getVersion() <= end; ++i )
    {
        if( !dataSent )
        {
            _sendMapSuccess( command, true );
            dataSent = true;
        }

        InstanceData* data = *i;
        LBASSERT( data );
        data->os.sendMapData( command.getRemoteNode(),
                              command.getInstanceID( ));

#ifdef CO_INSTRUMENT_MULTICAST
        ++_miss;
#endif
    }

    if( !dataSent )
    {
        _sendMapSuccess( command, false );
        _sendMapReply( command, replyVersion, true, replyUseCache, false );
    }
    else
        _sendMapReply( command, replyVersion, true, replyUseCache, true );

#ifdef CO_INSTRUMENT_MULTICAST
    if( _miss % 100 == 0 )
        LBINFO << "Cached " << _hit << "/" << _hit + _miss
               << " instance data transmissions" << std::endl;
#endif
    return true;
}