這篇文章主要介紹了Migrator類怎么用,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
成都創(chuàng)新互聯(lián)從2013年創(chuàng)立,先為臺州等服務建站,臺州等地企業(yè),進行企業(yè)商務咨詢服務。為臺州企業(yè)網(wǎng)站制作PC+手機+微官網(wǎng)三網(wǎng)同步一站式服務解決您的所有建站問題。
Migrator類說明:
class Migrator { MDSRank *mds; 記錄mds信息 MDCache *cache; 記錄MDCache信息 struct export_state_t { int state; 記錄export的當前狀態(tài) mds_rank_t peer; 記錄export到對端mds rank信息 uint64_t tid; 記錄export到對端的session id信息 set<mds_rank_t> warning_ack_waiting; 等待warning ack的mds集合 set<mds_rank_t> notify_ack_waiting; 等待notify ack的mds集合 map<inodeno_t, map<client_t, Capability::Import>> peer_imported; 記錄export對端信息 list<MDSInternalContextBase*> waiting_for_finish; 記錄等待finish的集合 MutationRef mut; MutationImpl對象引用 utime_t last_cum_auth_pins_change; int last_cum_auth_pins; int num_remote_waiters; 遠程auth pin waiters }; map<CDir*, export_state_t> export_state; export的狀態(tài)集合 list<pair<dirfrag_t, mds_rank_t>> export_queue; export隊列 struct import_state_t { int state; mds_rank_t peer; uint64_t tid; set<mds_rank_t> bystanders; list<dirfrag_t> bound_ls; list<ScatterLock*> updated_scatterlocks; map<client_t, entity_inst_t> client_map; map<CInode*, map<client_t, Capability::Export>> peer_exports; MutationRef mut; }; map<dirfrag_t, import_state_t> import_state; };
Migrator類方法:
Migrator::dispatch(m) 核心分發(fā)處理函數(shù)
|__根據(jù)m的類型決定后續(xù)的處理過程
|__類型是MSG_MDS_EXPORTDIRDISCOVER
|__調(diào)用handle_export_discover(MExportDirDiscover* m)
|__類型是MSG_MDS_EXPORTDIRPREP
|__調(diào)用handle_export_prep(MExportDirPrep* m)
|__類型是MSG_MDS_EXPORTDIR
|__調(diào)用handle_export_dir(MExportDir* m)
|__類型是MSG_MDS_EXPORTDIRFINISH
|__調(diào)用handle_export_finsih(MExportDirFinish* m)
|__類型是MSG_MDS_EXPORTDIRCANCEL
|__調(diào)用handle_export_cancel(MExportDirCancel* m)
|__類型是MSG_MDS_EXPORTDIRDISCOVERACK
|__調(diào)用handle_export_discover_ack(MExportDirDiscoverAck* m)
|__類型是MSG_MDS_EXPORTDIRPREACK
|__調(diào)用handle_export_prep_ack(MExportDirPrepAck* m)
|__類型是MSG_MDS_EXPORTDIRACK
|__調(diào)用handle_export_ack(MExportDirAck* m)
|__類型是MSG_MDS_EXPORTDIRNOTIFYACK
|__調(diào)用handle_export_notify_ack(MExportDirNotifyAck* m)
|__類型是MSG_MDS_EXPORTDIRNOTIFY
|__調(diào)用handle_export_dir_notify(MExportDirNotify* m)
|__類型是MSG_MDS_EXPORTCAPS
|__調(diào)用handle_export_caps(MExportCaps* m)
|__類型是MSG_MDS_GATHERCAPS
|__調(diào)用handle_gather_caps(MGatherCaps* m)
Migrator::export_empty_import(dir)
|__dir對應的inode節(jié)點是auth的
|__直接返回
|__dir是auth的
|__直接返回
|__dir是freezing或frozen
|__直接返回
|__dir不是空目錄
|__直接返回
|__dir是root節(jié)點
|__直接返回
|__得到export目的dir所在的mds節(jié)點,即:dir->inode->authority().first
|__調(diào)用export_dir(dir, dest) 執(zhí)行實際的export操作
Migrator::export_dir(dir, dest)
|__檢查MDCache是否是readonly(目前尚不支持read-only模式的export)
|__直接返回
|__檢查mdsmap是否是degraded(cluster處于degraded狀態(tài)則不能export)
|__直接返回
|__檢查dir的inode是否是system(不能export system dir)
|__直接返回
|__檢查dir的inode是否是stray
|__直接返回
|__檢查dir是否處于freezing或frozen
|__直接返回
|__檢查dir是否處于EXPORTING狀態(tài)
|__直接返回
|__執(zhí)行dir的auth_pin()
|__設(shè)置dir的當前狀態(tài)為EXPORTING,即:dir->state_set(STATE_EXPORTING)
|__從MDCache中得到MDRequestRef類對象,即:mds->mdcache->request_start_internal(EXPORTDIR)
|__設(shè)置MDRequest類對象中的_more的export_dir為dir,即:保存待export的dir數(shù)據(jù)
|__從export_state數(shù)組中得到dir為索引對應的export_state_t對象stat
|__設(shè)置stat的state為EXPORT_LOCKING
|__設(shè)置stat的peer為dest
|__設(shè)置stat的tid為mdr->reqid.tid
|__設(shè)置stat的mut為mdr
|__調(diào)用dispatch_export_dir(mdr)來發(fā)送export dir請求
Migrator::dispatch_export_dir(mdr)
|__從mdr的_more中得到待export的dir數(shù)據(jù),即:mdr->more()->export_dir
|__從export_state數(shù)組中找到dir對應的export state項
|__設(shè)置export_state_t的當前狀態(tài)是EXPORT_DISCOVERING
|__創(chuàng)建MExportDirDiscover類消息
|__將消息發(fā)送給目的MDS進程,即:mds->send_message_mds(discover, it->second.peer)
|__設(shè)置export_state_t中的last_cum_auth_pins_change為系統(tǒng)當前時間
|__freeze當前dir的tree,即:dir->freeze_tree()
|__添加dir等待WAIT_FROZEN的回調(diào)函數(shù)C_MDC_ExportFreeze(),即:調(diào)用export_frozen()函數(shù)
Migrator::handle_export_discover(MExportDirDiscover *m) (對端)
|__從消息中得到對端的mds_rank_t以及dirfrag_t結(jié)構(gòu),即:from=m->get_source_mds()/df = m->get_dirfrag()
|__遍歷import_state數(shù)組
|__若數(shù)組中沒有找到對應的項且m->started==false
|__設(shè)置m->started=true
|__更新import_state數(shù)組中對應的項,即:state=IMPORT_DISCOVERING/peer=from/tid=m->get_tid()
|__從MDCache中得到export的dir的CInode信息,即:in=cache->get_inode(m->get_dirfrag().ino)
|__更新import_state數(shù)組中對應的項,即:state==IMPORT_DISCOVERED
|__創(chuàng)建MExportDirDiscoverAck類消息
|__將類消息發(fā)送回給mds進程,即:mds->send_message_mds()
Migrator::handle_export_discover_ack(MExportDirDiscoverAck* m)
|__從消息中得到dirfrag,之后從MDCache中得到dirfrag對應的CDir類對象,即:cache->get_dirfrag(m->get_dirfrag())
|__在export_state數(shù)組中查找dir對應的項
|__在export_state數(shù)組對應的dir項中設(shè)置其狀態(tài)為EXPORT_FREEZING
Migrator::export_frozen(dir, tid)
|__從export_state數(shù)組中查找dir對應的項
|__得到該dir對應的CInode,即:dir->get_inode()
|__創(chuàng)建一個新的MutationImpl類對象且將其放入export_state_t的mut中
|__根據(jù)dirfrag和tid創(chuàng)建一個MExportDirPrep類消息
|__遍歷dir的replicas數(shù)組
|__將數(shù)組中的成員添加到MExportDirPrep類消息的bystander中
|__將basedir添加到MExportDirPrep類消息的basedir中
|__遍歷bounds數(shù)組
|__將bounds成員添加到MExportDirPrep類消息的bound中
|__循環(huán)處理如下內(nèi)容
|__將bounds成員的inode添加到inodes_added數(shù)組中
|__遍歷bounds成員的parent目錄
|__將dirfrag以及start信息序列化到bufferlist中
|__將bufferlist寫入到MExportDirPrep類消息的trace中
|__設(shè)置export_state_t中的狀態(tài)為EXPORT_PREPPING
|__將MExportDirPrep類消息發(fā)送給目的MDS,即:mds->send_message_mds()
Migrator::handle_export_prep(MExportDirPrep *m) (對端)
|__從import_state數(shù)組中找到消息中對應的dirfrag項
|__從MDCache中得到dir和dir對應的CInode
|__遍歷消息中的bounds數(shù)組
|__將數(shù)組中的內(nèi)容添加到import_bound_fragset數(shù)組中
|__若消息中的did_assim()==false
|__設(shè)置當前import_state數(shù)組中對應項的state為IMPORT_PREPPING
|__從消息中解析traces數(shù)組
|__將traces數(shù)組中的內(nèi)容添加到MDCache中
|__遍歷import_bound_fragset數(shù)組
|__從數(shù)組成員的inodeno_t的到對應的CInode結(jié)構(gòu)
|__調(diào)用CInode對應的get_stickydirs()函數(shù)
|__遍歷import_bound_fragset數(shù)組
|__從數(shù)組成員的inodeno_t的到對應的CInode結(jié)構(gòu)
|__遍歷數(shù)組成員中fragset_t下所有葉子節(jié)點
|__根據(jù)葉子節(jié)點得到在MDCache中對應的CDir數(shù)據(jù)
|__若CDir數(shù)據(jù)不在MDCache中
|__執(zhí)行MDCache中的open_remote_dirfrag()函數(shù)來創(chuàng)建這個CDir
|__將葉子節(jié)點對應的CDir數(shù)據(jù)插入到import_bounds數(shù)組中
|__設(shè)置import_state數(shù)組指定成員的狀態(tài)為IMPORT_PREPPED
|__創(chuàng)建MExportDirPreAck類消息
|__調(diào)用mds的send_message()方法將類消息發(fā)送給指定的MDS進程
Migrator::handle_export_prep_ack(MExportDirPrepAck *m)
|__根據(jù)消息的dirfrag得到對應的CDir類對象
|__在export_state數(shù)組中查找CDir類對象對應的項
|__遍歷replicas數(shù)組
|__將mds_rank_t信息插入到export_state_t結(jié)構(gòu)中的warning_ack_waiting/notify_ack_waiting數(shù)組中
|__創(chuàng)建MExportDirNotify類消息
|__將MEXportDirNotify類消息發(fā)送給對端mds進程
|__設(shè)置export_state_t結(jié)構(gòu)中的state為EXPORT_WARNING
Migrator::handle_export_notify(MExportDirNotify *m) (對端)
|__從MDCache中得到消息中dirfrag對應的CDir類對象
|__創(chuàng)建MExportDirNotifyAck類消息
|__調(diào)用mds的send_message_mds()將類消息發(fā)送回給mds進程
Migrator::handle_export_notify_ack(MExportDirNotifyAck *m)
|__根據(jù)消息的dirfrag得到對應的CDir類對象
|__從消息中得到對端mds_rank_t信息
|__若在export_state數(shù)組中能夠找到dir對應的項
|__若export_state_t的state==EXPORT_WARNING
|__調(diào)用export_go(dir) 執(zhí)行實際的export操作
|__若export_state_t的state==EXPORT_NOTIFYING
|__調(diào)用export_finish(dir)
Migrator::export_go(dir)
|__調(diào)用哦mds中mdlog的wait_for_safe()函數(shù)來設(shè)置回調(diào)函數(shù)C_M_ExportGo(),最后執(zhí)行export_go_synced(dir, tid)
|__flush mds的mdlog,即:|mds->mdlog->flush()
Migrator::export_go_synced(dir, tid)
|__在export_state數(shù)組中查找dir對應的項
|__設(shè)置其狀態(tài)為EXPORT_EXPORTING
|__創(chuàng)建MExportDir類消息
|__調(diào)用encode_export_dir()得到export的map信息以及得到exported_inodes數(shù)量
|__將得到的export的map信息序列化到類消息的client_map中
|__遍歷bounds數(shù)組
|__將數(shù)組中的成員添加到類消息的export數(shù)組中
|__發(fā)送類消息到對端mds進程,即:mds->send_message_mds()
Migrator::handle_export_dir(MExportDir *m) (對端)
|__從MDCache中得到消息中dirfrag對應的CDir類對象
|__從import_state數(shù)組中查到消息中dirfrag對象的項
|__創(chuàng)建C_MDS_ImportDirLoggedStart回調(diào)函數(shù)類
|__創(chuàng)建EImportStart日志入口
|__調(diào)用MDS的mlog的start_entry()來啟動日志
|__將消息中的client_map信息解析道EImportStart中的imported_client_map中
|__從消息中得到export_data
|__調(diào)用decode_import_dir()函數(shù),將export_data寫入到mdlog對應的current segment里
|__遍歷消息中的bounds數(shù)組
|__將數(shù)組中dirfrag_t對應的CDir添加到LogSegment中
|__將數(shù)組中dirfrag_t對應的CDir添加到import_bounds數(shù)組中
|__調(diào)用mds的balancer的add_import()函數(shù)來平衡查找樹
|__設(shè)置import_state_t中的狀態(tài)為IMPORT_LOGGINGSTART
|__啟動mdlog,即:mds->mdlog->submit_entry()/mds->mdlog->flush()
Migrator::import_logged_start() (對端)
|__在import_state數(shù)組中查找dirfrag對應的項
|__設(shè)置對應項的state為IMPORT_ACKING
|__創(chuàng)建MExportDirAck類對象
|__發(fā)送MExportDirAck類對象到mds進程
Migrator::handle_export_ack(MExportDirAck *m)
|__在export_state數(shù)組中查找dirfrag對應的項
|__將消息中的imported_caps解析到export_state_t中的peer_imported中
|__設(shè)置對應項的state為EXPORT_LOGGINGFINISH
|__創(chuàng)建EExport類對象
|__將bounds數(shù)組中的內(nèi)容寫入到EExport類對象的metablob中
|__創(chuàng)建C_MDS_ExportFinishLogged回調(diào)函數(shù)類
|__啟動mdlog,即:mds->mdlog->submit_entry()/mds->mdlog->flush()
Migator::export_logged_finish(dir)
|__查找export_state數(shù)組中指定dir的export_state_t項
|__遍歷export_state_t項中的notify_ack_waiting數(shù)組
|__創(chuàng)建MExportDirNotify類消息
|__發(fā)送MExportDirNotify類消息到mds進程
|__設(shè)置export_state_t中的狀態(tài)為EXPORT_NOTIFYING
|__創(chuàng)建MExportDirFinish類消息
|__發(fā)送MExportDirFinish類消息到mds進程
Migrator::handle_export_finish(MExportDirFinish *m) (對端)
|__在import_state數(shù)組中找到對應項
|__調(diào)用import_finish()函數(shù)
Migrator::import_finish(dir, notify, last) (對端)
|__從import_state數(shù)組中得到指定dirfrag
|__若state==IMPORT_ACKING
|__遍歷import_state_t中的peer_exports數(shù)組
|__更新MDCache中的內(nèi)容
|__若last==false
|__設(shè)置state=IMPORT_FINISHING
|__直接返回
|__處理MDCache中的內(nèi)容
=======================export client maps and client caps
Migrator::encode_export_inode_caps(in, auth_cap, bl, exported_client_map) 得到client map以及client caps map
|__調(diào)用in->export_client_caps()函數(shù),得到in的client capability map信息
|__將client capability map信息序列化到bl中
|__遍歷in的client_caps數(shù)組
|__從mds的sessionmap中得到client_caps數(shù)組成員對應的信息并寫入到exported_client_map中
Migrator::export_caps(CInode *in)
|__從in中得到授權(quán)的mds_rank_t信息,即:in->authority().first
|__創(chuàng)建MExportCaps類消息
|__設(shè)置類消息的ino為in->ino()
|__調(diào)用encode_export_inode_caps()
|__調(diào)用mds的send_message_mds()函數(shù)將MExportCaps消息發(fā)送給指定的MDS進程
Migrator::handle_export_caps(MExportCaps *ex)
|__從MDCache中得到類消息中的CInode信息,即:in=cache->get_inode(ex->ino)
|__若in處于frozen狀態(tài)
|__直接返回
|__創(chuàng)建C_M_LoggedImportCaps回調(diào)函數(shù)類
|__將類消息中的client_map信息寫入到回調(diào)函數(shù)類的client_map中
|__調(diào)用decode_import_inode_caps()函數(shù)將類消息中的client caps信息反序列化并保存到peer_exports數(shù)組中
|__創(chuàng)建ESession類型的LogEvent類消息(client_map)
|__寫mdlog日志,即:mds->mdlog->start_submit_entry()
|__調(diào)用mds->mdlog->flush() 刷mdlog日志
Migrator::handle_gather_caps(MGatherCaps *m)
|__從MDCache中得到類消息對應的CInode信息,即:cache->get_inode(m->ino)
|__若in存在caps并且in不存在auth并且in沒有EXPORTINGCAPS
|__調(diào)用export_caps(in) 將in對應的client maps和client caps map export出去
Migrator導入導出狀態(tài)機處理過程如下圖所示:
感謝你能夠認真閱讀完這篇文章,希望小編分享的“Migrator類怎么用”這篇文章對大家有幫助,同時也希望大家多多支持創(chuàng)新互聯(lián),關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關(guān)知識等著你來學習!
名稱欄目:Migrator類怎么用
本文鏈接:http://jinyejixie.com/article16/iicsgg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google、網(wǎng)站維護、品牌網(wǎng)站建設(shè)、小程序開發(fā)、定制網(wǎng)站、靜態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)