...
type | zxid | data | notation | meaning | |
---|---|---|---|---|---|
FOLLOWERINFO(11) | acceptedEpoch | LearnerInfo | FOLLOWERINFO(acceptedEpoch) | The follower has accepted epoch acceptedEpoch. | |
DIFF(13) | last committed zxid | n/a | DIFF(lastCommittedZxid) | lastCommittedZxid is the last zxid committed by the leader. | |
TRUNC(14) | truncZxid | n/a | TRUNC(truncZxid) | Truncate the history to truncZxid | |
SNAP(15) | n/a | n/a | SNAP | A state transfer (aka snapshot) will be sent to the follower. this will be a fuzzy state transfer that may include zxids being sent to the follower. The state transfer will immediately follow this packet. | |
OBSERVERINFO(16) | last zxid learned | LearnerInfo | OBSERVERINFO(lastZxid) | The observer has accepted up to lastZxid. | |
NEWEPOCH SERVERINFO(17) | proposed epoch | n/a protocol | NEWEPOCH SERVEREINFO(e) | The new proposed epoch | |
ACKEPOCH(18) | accepted epoch | lastZxid | currentEpoch n/a | ACKEPOCH(elastZxid, currentEpoch) | Acknowledge the acceptance of the new epoch |
NEWLEADER(10) | e << 32 | n/a | NEWLEADER(e) | Accept this leader as the leader of the epoch e. | |
UPTODATE(12) | n/a | n/a | UPTODATE | The follower is now uptodate enough to begin serving clients. | |
PROPOSAL(2) | zxid of proposal | proposed message | PROPOSAL(zxid, data) | Propose a message. (Request that it be accepted into a followers history.) | |
ACK(3) | zxid of proposal to ack | n/a | ACK(zxid) | Everything sent to the follower by the leader up to zxid has been accepted into its history (logged to disk). | |
COMMIT(4) | zxid of proposal to commit | n/a | COMMIT(zxid) | Everything in the followers history up to zxid should be committed (aka delivered). | |
INFORM(8) | zxid of proposal | data of proposal | INFORM(zxid, data) | Deliver the data. (Only used with observers.) |
...
- l The leader starts accepting connections from followers.
- f Followers connect the the leader and send FollowerInfoFOLLOWERINFO.
- l Once the leader has quorum, it stops accepting connections, and sends ServerInfo SERVERINFO(e) to all followers, where e is greater than all f.acceptedEpoch in the quorum.
- f When the follower receives ServerInfo SERVERINFO(e) it will do one of the following, where e = ServerInfo.proposedEpoch:
- if e > f.acceptedEpoch, the the follower sets f.acceptedEpoch = e and sends ACKACKEPOCH(e<<32e);
- if e == f.acceptedEpoch, the follower does not send AckNewEpochACKEPOCH, but continues to next step;
- if e < f.acceptedEpoch, the follower closes the connection to the leader and goes back to leader election;
- l The leader waits for a quorum of followers to send AckNewEpochACKEPOCH.
- l If the following conditions are not met for all connected followers, the leader disconnects followers and goes back to leader election:
- f.currentEpoch <= l.currentEpoch
- if f.currentEpoch == l.currentEpoch, then f.lastZxid <= l.lastZxid
...