久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

Ceph Monitor Paxos算法怎么用

共計(jì) 4052 個(gè)字符,預(yù)計(jì)需要花費(fèi) 11 分鐘才能閱讀完成。

丸趣 TV 小編給大家分享一下 Ceph Monitor Paxos 算法怎么用,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

一些相關(guān)變量

last_pn:最新的 proposal number;

accepted_pn:最新的接受的 proposal number;

accepted_pn_from:peon 接受最新的 proposal number 的 leader 的 last_committed(也就是說(shuō)只接受比 accepted_pn_from 大的 pn 值)

first_committed:

last_committed:leader 和 peon 都存在的,接受最新 value 的版本號(hào);

peer_first_committed:記錄集群成員中第一次 commit 的版本號(hào);

peer_last_committed:記錄集群成員中最新 commit 的版本號(hào);

一些函數(shù)解析

Paxos::init()

      從 MonitorDB 中讀取 last_pn/accepted_pn/last_committed/first_committed 的值;

leader

     Paxos::collect()

     |__state = STATE_RECOVERING           設(shè)置當(dāng)前狀態(tài)為 RECOVERING

     |__初始化相關(guān)變量 uncommitted_v/uncommitted_pn/uncommitted_value/peer_first_committed/peer_last_committed

     |__檢查是否存在 uncommitted value 存在,通過(guò)查看 MonitorDB 中是否存在 last_committed+ 1 的值存在,若存在則初始化 uncommitted_pn/uncommitted_v/uncommitted_value

     |__Paxos::get_new_proposal_number()                     生成一個(gè)單調(diào)遞增的且全局唯一的 last_pn 值

     |__初始化 accepted_pn=last_pn/accepted_pn_from=last_committed

     |__遍歷 mon- get_quorum(),創(chuàng)建 MMonPaxos 消息且設(shè)置消息的 last_committed/first_committed/pn(accepted_pn)

     |__向 mon- get_quorum() 中所有 monitor 節(jié)點(diǎn)發(fā)送 MMonPaxos 消息

     Paxos::handle_last()

     |__更新 peer_first_committed/peer_last_committed 數(shù)組

     |__對(duì)于 peon.first_committed leader.last_committed+1,則 leader 調(diào)用 mon- bootstrap()

     |__Paxos::store_state()                     保存 MMonPaxos 消息中 value 值的 version_t leader.last_committed version_t =peon.last_committed 到 leader 的 MonitorDB 中

     |__遍歷 peer_last_committed 數(shù)組中所有 peon,對(duì)于數(shù)組中 peon.version_t leader.last_committed 來(lái)說(shuō),創(chuàng)建 MMonPaxos 消息且消息類型是 MMonPaxos::OP_COMMIT 且將該消息發(fā)送給 peon

     |__對(duì)于 peon.accepted_pn leader.accepted_pn,則調(diào)用 Paxos::collect()

     |__對(duì)于 peon.accetped_pn == leader.accepted_pn,則認(rèn)為 peon 認(rèn)可 leader 的 proposal number,對(duì)于所有 peon 都認(rèn)可 leader 的 proposal number,則設(shè)置當(dāng)前狀態(tài)為 STATE_UPDATING_PREVIOUS

     |__Paxos::begin(),調(diào)用參數(shù)是 peon 傳過(guò)來(lái)的 uncommitted_value

     Paxos::begin()

     |__初始化 accepted 數(shù)組

     |__對(duì)于 last_committed== 0 的情況,設(shè)置 first_committed=1

     |__將參數(shù)中傳遞進(jìn)來(lái)的 peon 的 uncommitted_value 寫入到 MonitorDB 中

     |__更新 pending_v = last_committed+1/pending_pn=aceepted_pn 且寫入到 MonitorDB 中

     |__遍歷 mon- get_quorum(),創(chuàng)建 MMonPaxos 消息且設(shè)置消息類型是 MMonPaxos::OP_BEGIN

     |__設(shè)置消息的 pn=accepted_pn/last_committed=last_committed/value[last_committed+1]=new_value

     |__發(fā)送 MMonPaxos 消息到 peon

     Paxos::handle_accept()

     |__對(duì)于 peon.accepted_pn != leader.accepted_pn,則直接拒絕

     |__將 peon 插入到 accepted 數(shù)組中

     |__若所有 peon 都返回 OP_ACCEPT 消息,則調(diào)用 Paxos::commit_start()

     Paxos::commit_start()

     |__寫 last_committed=last_committed+ 1 到 MonitorDB 中

     |__將 uncommited_value 寫入到 MonitorDB 中

     |__寫 MonitorDB 成功后回調(diào) Paxos::commit_finish() 函數(shù)

     Paxos::commit_finish()

     |__遍歷 mon- get_quorum(),創(chuàng)建 MMonPaxos 消息且消息類型是 MMonPaxos::OP_COMMIT

     |__設(shè)置消息的 value[last_committed]=new_value/pn=accepted_pn/last_committed=last_committed

     |__將消息發(fā)送給 peon

     |__設(shè)置當(dāng)前狀態(tài)為 STATE_REFRESH

peon

     Paxos::handle_collect()

     |__state = STATE_RECOVERING           設(shè)置當(dāng)前狀態(tài)為 RECOVERING

     |__對(duì)于 leader 的 first_committed peon 的 last_committed+1,則調(diào)用 mon- bootstrap()

     |__創(chuàng)建 MMonPaxos 消息且設(shè)置消息類型為 MMonPaxos::OP_LAST

     |__設(shè)置消息的 last_committed/first_committed

     |__若 leader.accepted_pn peon.accepted_pn,則設(shè)置 peon.accepted_pn=leader.accepted_pn,同時(shí)設(shè)置 peon.accepted_pn_from=leader.pn_from

     |__將 peon.accepted_pn 寫入到 MonitorDB 中

     |__設(shè)置 MMonPaxos 消息的 pn/pn_from=accepted_pn/accepted_pn_from

     |__若 leader.last_committed peon.last_committed,則說(shuō)明 peon 存在 uncommitted value,于是從 MonitorDB 讀取出 pending_pn/pending_value 且設(shè)置到 MMonPaxos 消息中的 uncommitted_pn/value[pending_v] 中

     |__發(fā)送 MMonPaxos 消息給 leader

     Paxos::handle_begin()

     |__對(duì)于 leader.pn peon.accepted_pn,則直接拒絕

     |__state = STATE_UPDATING

     |__保存 leader.uncommitted_value 到 MonitorDB

     |__保存 pending_v=last_committed+1/pending_pn=accepted_pn 到 MonitorDB

     |__創(chuàng)建 MMonPaxos 消息且設(shè)置消息類型為 MMonPaxos::OP_ACCEPT

     |__設(shè)置消息 pn=accepted_pn/last_committed=last_committed

     |__將 MMonPaxos 消息發(fā)送給 leader

     Paxos::handle_commit()

     |__Paxos::store_state()           將 leader committed 的 value 寫入到 MonitorDB 中

leader 和 peon 之間的處理流程對(duì)應(yīng)關(guān)系如下:

leader                                             peon

     collect()                                          handle_collect()

     handle_last()                                  

     begin()                                            handle_begin()

     handle_accept()

     commit_start()

     commit_finish()                              handle_commit()

以上是“Ceph Monitor Paxos 算法怎么用”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注丸趣 TV 行業(yè)資訊頻道!

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-08-16發(fā)表,共計(jì)4052字。
轉(zhuǎn)載說(shuō)明:除特殊說(shuō)明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請(qǐng)注明出處。
評(píng)論(沒(méi)有評(píng)論)
主站蜘蛛池模板: 新乐市| 临潭县| 孟村| 邵东县| 鸡西市| 册亨县| 扶风县| 紫阳县| 贵溪市| 平果县| 那曲县| 乐都县| 涡阳县| 繁峙县| 高淳县| 吴川市| 射阳县| 平泉县| 遵化市| 黎平县| 闸北区| 沙田区| 通海县| 文水县| 泾川县| 封丘县| 怀柔区| 南平市| 定安县| 金沙县| 屯门区| 临潭县| 明星| 望奎县| 晋江市| 龙川县| 安远县| 巴彦淖尔市| 华蓥市| 贵港市| 岳阳市|