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; }
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; }
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; }
void ObjectCM::_addSlave( MasterCMCommand command, const uint128_t& version ) { LBASSERT( version != VERSION_NONE ); LBASSERT( command.getType() == COMMANDTYPE_NODE ); LBASSERT( command.getCommand() == CMD_NODE_MAP_OBJECT ); // process request if( command.getRequestedVersion() == VERSION_NONE ) { // no data to send, send empty version _sendMapSuccess( command, false /* mc */ ); _sendEmptyVersion( command, VERSION_NONE, false /* mc */ ); _sendMapReply( command, VERSION_NONE, true, false, false /* mc */ ); return; } const bool replyUseCache = command.useCache() && (command.getMasterInstanceID() == _object->getInstanceID( )); _initSlave( command, version, replyUseCache ); }