baidu / braft

An industrial-grade C++ implementation of RAFT consensus algorithm based on brpc, widely used inside Baidu to build highly-available distributed systems.
Apache License 2.0
3.99k stars 886 forks source link

API exposed to raft leader when follower node goes down in braft implementation #474

Open s-rajpoot opened 1 month ago

s-rajpoot commented 1 month ago

I am using Raft (braft library) for high availability. I have 3 applications (Nodes) forming raft cluster. I have to manage application (Node) states (ONLINE, OFFLINE). If leader goes down and another node becomes leader there are api's exposed to application which becomes leader(on_leader_start()). Similarly does braft provides any api or method exposed to leader application when follower goes down (Unplanned shutdown) or joins the raft cluster?

For example: I have the following scenarios.

          scenario 1.

          App1(leader, state: ONLINE), App2(follower, state: ONLINE), App3(follower, state: ONLINE) 
          App2 goes down (Unplanned shutdown)
          I have to manage Node states App1(state: ONLINE), App2(state: OFFLINE), App3(state: ONLINE)
          How will braft notify App1(leader) that App2 is down.

          scenario 2.

          App1(leader, state: ONLINE), App2(follower, state: OFFLINE), App3(follower, state: ONLINE)  
          App2 rejoins the raft cluster.
          I have to manage Node states App1(state: ONLINE), App2(state: ONLINE), App3(state: ONLINE)
          How will braft notify App1(leader) that App2 has joined the cluster.