Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report