這篇文章主要介紹MDSTable相關(guān)內(nèi)容有哪些,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
創(chuàng)新互聯(lián)公司擁有10年成都網(wǎng)站建設(shè)工作經(jīng)驗,為各大企業(yè)提供成都網(wǎng)站設(shè)計、網(wǎng)站制作、外貿(mào)營銷網(wǎng)站建設(shè)服務,對于網(wǎng)頁設(shè)計、PC網(wǎng)站建設(shè)(電腦版網(wǎng)站建設(shè))、重慶App定制開發(fā)、wap網(wǎng)站建設(shè)(手機版網(wǎng)站建設(shè))、程序開發(fā)、網(wǎng)站優(yōu)化(SEO優(yōu)化)、微網(wǎng)站、空間域名等,憑借多年來在互聯(lián)網(wǎng)的打拼,我們在互聯(lián)網(wǎng)網(wǎng)站建設(shè)行業(yè)積累了很多網(wǎng)站制作、網(wǎng)站設(shè)計、網(wǎng)絡營銷經(jīng)驗,集策劃、開發(fā)、設(shè)計、營銷、管理等網(wǎng)站化運作于一體,具備承接各種規(guī)模類型的網(wǎng)站建設(shè)項目的能力。
對MDSTable的操作主要是對version和state保存到集群以及從集群中讀取的操作。具體操作處理函數(shù)說明如下:
MDSTable::save()
|__對version和state進行encode操作
|__設(shè)置committing_version = version 設(shè)置committing_version
|__設(shè)置waitfor_save[version].push_back(onfinish)
|__get_object_name() 得到對象名稱mds_${table_name}
|__得到object_locator_t類實例,即:將數(shù)據(jù)存放到metadata pool中
|__mds->object_write_full() 將version和state的encode數(shù)據(jù)寫入到metadata pool中的mds_${table_name}對象中
MDSTable::save_2()
|__committed_version = v 設(shè)置committed_version
|__遍歷waitfor_save數(shù)組
|__對于waitfor_save[i]->first <=v的,從waitfor_save數(shù)組中刪除
MDSTable::reset()
|__reset_state()
|__state = STATE_ACTIVE 設(shè)置state當前值
MDSTable::load()
|__state = STATE_OPENING 設(shè)置state當前值
|__get_object_name() 得到對象名稱mds_${table_name}
|__得到object_locator_t類實例,即:將數(shù)據(jù)存放到metadata pool中
|__mds->objecter->read_full() 從集群中獲取MDSTable信息
MDSTable::load_2()
|__state = STATE_ACTIVE
|__若r == -EBLACKLISTED,則調(diào)用mds->respawn()
|__若r < 0,則調(diào)用mds->damaged()
|__從集群的得到version值且設(shè)置projected_version=committed_version=version
|__從集群中得到state信息
MDSTableServer類繼承MDSTable類
class MDSTableServer : public MDSTable {
int table;
map
};
MDSTableServer::handle_request() 總路由調(diào)度函數(shù),負責將請求分派給不同的handle_*()來處理
|__TABLESERVER_OP_QUERY
|__handle_query()
|__TABLESERVER_OP_PREPARE
|__handle_prepare()
|__TABLESERVER_OP_COMMIT
|__handle_commit()
|__TABLESERVER_OP_ROLLBACK
|__handle_rollback()
MDSTableServer::handle_prepare()
|___prepare() 調(diào)用子類的_prepare()函數(shù)從request消息中得到具體的信息
|___note_prepare() 填充pending_for_mds數(shù)組
|__創(chuàng)建ETableServer類對象
|__mds->mdlog->submit_entry() 寫log
|__mds->mdlog->flush()
MDSTableServer::_prepare_logged() 該函數(shù)是handle_prepare()執(zhí)行完寫log后的回調(diào)函數(shù)
|__創(chuàng)建MMDSTableRequest類消息(TABLESERVER_OP_AGREE)
|__mds->send_message_mds() 將類消息發(fā)送回給調(diào)用handle_prepare()的對端
MDSTableServer::handle_commit()
|__檢查pending_for_mds數(shù)組中是否包含對應的項
|___commit() 執(zhí)行子類的commit操作
|___note_commit() 刪除pending_for_mds數(shù)組中對應的項
|__mds->mdlog->start_submit_entry() 寫log
MDSTableServer::_commit_logged() 該函數(shù)是handle_commit()執(zhí)行完寫log后的回調(diào)函數(shù)
|__創(chuàng)建MMDSTableRequest類消息(TABLESERVER_OP_ACK)
|__mds->send_message_mds() 將類消息發(fā)送回給調(diào)用handle_prepare()的對端
MDSTableServer::handle_rollback()
|___rollback() 執(zhí)行子類的rollback操作
|___note_rollback() 刪除pending_for_mds數(shù)組中對應的項
|___mds->mdlog->start_submit_entry() 寫log
MDSTableServer::do_server_update()
|__創(chuàng)建ETableServer類實例
|__mds->mdlog->start_entry()
|__mds->mdlog->submit_entry() 寫log
MDSTableServer::finish_recovery()
|__遍歷參數(shù)中的mds_rank_t集合
|__handle_mds_recovery()
MDSTableServer::handle_mds_recovery()
|__遍歷pending_for_mds數(shù)組
|__創(chuàng)建MMDSTableRequest類消息(TABLESERVER_OP_AGREE)
|__mds->send_message_mds() 發(fā)送mds消息
|__創(chuàng)建MMDSTableRequest類消息(TABLESERVER_OP_SERVER_READY)
|__mds->send_message_mds() 發(fā)送mds消息
SnapServer類繼承于MDSTableServer,用來記錄需要進行Snap操作的相關(guān)信息
class SnapServer: public MDSTableServer {
MonClient *mon_client; 與monitor交互的client端
snapid_t last_snap;
map
map
map
map
set
version_t last_checked_osdmap;
};
SnapServer::reset_state() 清空snaps和need_to_purge這兩個數(shù)組,之后獲取last_snap值
|__設(shè)置last_snap=1
|__清除snaps和need_to_purge數(shù)組
|__遍歷mds使用的osdmap
|__遍歷mdsmap使用的所有data pools
|__從osdmap中得到data pool對應的pg_pool_t結(jié)構(gòu)
|__對于pg_pool_t結(jié)構(gòu)中removed_snaps數(shù)組不為空,則取removed_snaps.range_end()最大值
|__設(shè)置last_snap = removed_snaps.range_end()的最大值
SnapServer::_prepare()
|__TABLE_OP_CREATE
|__更新version值(version++)
|__從參數(shù)bufferlist中得到SnapInfo信息(ino/name/stamp)
|__設(shè)置SnapInfo的snapid = ++last_snap/long_name=“create"
|__更新pending_update[version] = info
|__TABLE_OP_DESTROY
|__從參數(shù)bufferlist中得到inodeno_t和snapid_t的值
|__更新version值和last_snap值(version++/++last_snap)
|__更新pending_destroy[version]數(shù)組
|__TABLE_OP_UPDATE
|__從參數(shù)bufferlist中得到SnapInfo信息(ino/snapid/name/stamp)
|__更新version值和last_snap值(version++/++last_snap)
|__更新pending_update[version] = info
SnapServer::_is_prepared()
|__判斷pending_update或pending_destroy數(shù)組中是否包含參數(shù)指定的tid
SnapServer::_commit()
|__待commit的tid在pending_update數(shù)組中
|__從pending_update數(shù)組中得到指定tid的SnapInfo值
|__更新snaps[info.snapid] = info
|__刪除pending_update[tid]
|__待commit的tid在pending_destroy數(shù)組中
|__從pending_destroy數(shù)組中得到指定tid對應的snapid和last_snapid
|__從snaps數(shù)組中刪除snapid對應的值
|__遍歷mdsmap所有的data pools
|__更新need_to_purge數(shù)組(need_to_purge[*p].insert(snapid)/need_to_purge[*p].insert(last_snapid)
|__刪除pending_destroy[tid]
|__更新version (version++)
SnapServer::_rollback()
|__在pending_update/pending_destroy數(shù)組中刪除掉指定tid的值
SnapServer::_server_update()
|__從參數(shù)bufferlist中得到map
|__遍歷purge
|__刪除need_to_purge中指定的內(nèi)容
|__更新version
SnapServer::check_osd_map()
|__遍歷mds對應的所有osdmap
|__遍歷need_to_purge數(shù)組
|__從osdmap中得到pg_pool_t數(shù)據(jù)結(jié)構(gòu)的值
|__若pg_pool_t為空,則設(shè)置all_purged[id] = need_to_purge[id].all
|__遍歷need_to_purge數(shù)組的第二個參數(shù)
|__若pg_pool_t->is_removed_snap(i),則設(shè)置all_purged[id].push_back(i),否則設(shè)置all_purge[id].push_back(i)
|__對于all_purged數(shù)組不為空
|__將all_purged數(shù)組序列化
|__MDSTableServer::do_server_update()
|__SnapServer::_server_update()
|__創(chuàng)建ETableServer類對象
|__mds->mdlog->start_entry()
|__mds->mdlog->submit_entry() 寫log
|__對于all_purge數(shù)組不為空
|__創(chuàng)建MRemoveSnaps類消息
|__mon_client->send_mon_message() 將消息發(fā)送給monitor來刪除對應的snaps
MDSTable/MDSTableServer/SnapServer之間的關(guān)系如下圖所示:
以上是“MDSTable相關(guān)內(nèi)容有哪些”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!