Example #1
0
bool ObjectCM::sendSync( const MasterCMCommand& command )
{
    lunchbox::ScopedFastWrite mutex( _lock );
    if( !_object )
    {
        LBWARN << "Sync from detached object requested" << std::endl;
        return false;
    }

    const uint128_t& maxCachedVersion = command.getMaxCachedVersion();
    const bool useCache =
        command.useCache() &&
        command.getMasterInstanceID() == _object->getInstanceID() &&
        maxCachedVersion == getVersion();

    if( !useCache )
    {
        ObjectInstanceDataOStream os( this );
        os.enableSync( getVersion(), command );
        _object->getInstanceData( os );
        os.disable();
    }
    NodePtr node = command.getNode();
    node->send( CMD_NODE_SYNC_OBJECT_REPLY, useCache /*preferMulticast*/ )
        << node->getNodeID() << command.getObjectID() << command.getRequestID()
        << true << command.useCache() << useCache;
    return true;
}
Example #2
0
void ObjectCM::_sendMapSuccess( const MasterCMCommand& command,
                                const bool multicast )
{
    command.getNode()->send( CMD_NODE_MAP_OBJECT_SUCCESS, multicast )
            << command.getNode()->getNodeID() << command.getObjectID()
            << command.getRequestID() << command.getInstanceID()
            << _object->getChangeType() << _object->getInstanceID();
}
Example #3
0
void ObjectCM::_sendMapReply( const MasterCMCommand& command,
                              const uint128_t& version, const bool result,
                              const bool useCache, const bool multicast )
{
    command.getNode()->send( CMD_NODE_MAP_OBJECT_REPLY, multicast )
            << command.getNode()->getNodeID() << command.getObjectID()
            << version << command.getRequestID() << result
            << command.useCache() << useCache;
}
Example #4
0
bool FullMasterCM::sendSync( const MasterCMCommand& command )
{
    //const uint128_t& version = command.getRequestedVersion();
    const uint128_t& maxCachedVersion = command.getMaxCachedVersion();
    const bool useCache =
        command.useCache() &&
        command.getMasterInstanceID() == _object->getInstanceID() &&
        maxCachedVersion == _version;

    if( !useCache )
    {
        Mutex mutex( _slaves );
        InstanceData* instanceData = _instanceDatas.back();
        instanceData->os.sync( command );
    }

    NodePtr node = command.getNode();
    node->send( CMD_NODE_SYNC_OBJECT_REPLY, useCache /*preferMulticast*/ )
        << node->getNodeID() << command.getObjectID() << command.getRequestID()
        << true << command.useCache() << useCache;
    return true;
}