Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Analysis of information interaction between leader and follower during startup in zk

Shulou Source: shulou.com Published: 2022-06-02 00:00:08 10月05日 Update

This article focuses on "Information interaction Analysis of leader and follower startup in zk". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn "zk leader and follower startup information interaction analysis" it!

Read node state information in QuorumPeer and set different roles in different states

1 Leader starts Follower receiver LearnerCnxAcceptor

LearnerCnxAcceptor is responsible for receiving non-leader connection requests and creating a LearnerHandler processor in the thread

2 Learner initiates a connection to leader

Follower.followLeader ()

Observer.observeLeader ()

3 LearnerHandler is created when leader starts

Each learnerHandler instance corresponds to a connection between leader and learner, which is responsible for message communication and

Data synchronization

4 register with leader

After learner and leader are connected. Will register with leader, that is, learner server basic information

LearnerInfo zxid,sid sends to leader server

5 leader receives learner information server calculates the latest epoch

@ Overridepublic long getEpochToPropose (long sid, long lastAcceptedEpoch) throws InterruptedException, IOException {synchronized (connectingFollowers) {if (! waitingForNewEpoch) {return epoch;} if (lastAcceptedEpoch > = epoch) {epoch = lastAcceptedEpoch + 1;} if (isParticipant (sid)) {connectingFollowers.add (sid);} QuorumVerifier verifier = self.getQuorumVerifier () If (connectingFollowers.contains (self.getId ()) & & verifier.containsQuorum (connectingFollowers)) {waitingForNewEpoch = false; self.setAcceptedEpoch (epoch); connectingFollowers.notifyAll ();} else {long start = Time.currentElapsedTime (); if (sid = = self.getId ()) {timeStartWaitForEpoch = start } long cur = start; long end = start + self.getInitLimit () * self.getTickTime (); while (waitingForNewEpoch & & cur < end & &! quitWaitForEpoch) {connectingFollowers.wait (end-cur); cur = Time.currentElapsedTime () } if (waitingForNewEpoch) {throw new InterruptedException ("Timeout while waiting for epoch from quorum");}} return epoch;}} so far, I believe you have a deeper understanding of "Information interaction Analysis at startup of leader and follower in zk". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Information analysis server service different content status learning practical deeper between can create interest foundation processor instance practical practical receiver easy to operate Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Docker Shulou Information Shulou Technology Microsoft