As mentioned in the previous article, the raft core section only needs to use 2 RPC: requestvote and Appendentries, this article describes the format and role of these two RPC.
Requestvote RPC is sent by candidate to other nodes, requesting other nodes to vote for themselves, and if a candidate obtains a majority of the node's votes, the candidate is converted to leader. Appendentries RPC is sent by the leader node to other nodes, there are two functions, when its entries domain is empty, the RPC as leader heartbeat, when the entries domain is not empty, Request the other node to add the log from the entries domain to its own log.
Each raft node will process the RPC requests based on the state data of its own node, so let's take a look at each of the raft nodes to save those state data:
Here is the format and description of the Appendentries RPC:
The following is the Requestvote RPC format and Description:
The above two RPCs are all RPC used in the Raft core section. The following is a list of the rules for RPC and state transitions for raft nodes in various states:
This article describes the detailed format and processing flow of the raft core RPC call, and the next article will explain the process of raft log replication in conjunction with the content described in this article.
Raft Series article three: Raft RPC detailed