1
0
mirror of https://github.com/Snailclimb/JavaGuide synced 2025-06-16 18:10:13 +08:00

[docs]:modify pic format

This commit is contained in:
谢其骏 2022-01-27 14:44:32 +08:00
parent eee7a3bd12
commit 09a218f744

View File

@ -26,7 +26,7 @@
![rsm-architecture](https://github.com/jun0315/JavaGuide/blob/raft-pic/media/pictures/raft/rsm-architecture.png?raw=ture)
<center>图-1 复制状态机架构</center>
`图-1 复制状态机架构`
一般通过使用复制日志来实现复制状态机。每个`Server`存储着一份包括命令序列的日志文件,状态机会按顺序执行这些命令。因为每个日志包含相同的命令,并且顺序也相同,所以每个状态机处理相同的命令序列。由于状态机是确定性的,所以处理相同的状态,得到相同的输出。
@ -54,13 +54,13 @@
![rsm-architecture](https://github.com/jun0315/JavaGuide/blob/raft-pic/media/pictures/raft/server-state.png?raw=ture)
<center>图-2服务器的状态</center>
`图-2服务器的状态`
### 2.2 任期
![rsm-architecture](https://github.com/jun0315/JavaGuide/blob/raft-pic/media/pictures/raft/term.png?raw=ture)
<center>图-3任期<center>
`图-3任期`
如图3所示raft算法将时间划分为任意长度的任期term任期用连续的数字表示看作当前term号。每一个任期的开始都是一次选举在选举开始时一个或多个Candidate会尝试成为Leader。如果一个Candidate赢得了选举它就会在该任期内担任Leader。如果没有选出Leader将会开启另一个任期并立刻开始下一次选举。raft算法保证在给定的一个任期最少要有一个Leader。