zhuxt2015 commented on issue #10874:
URL: 
https://github.com/apache/dolphinscheduler/issues/10874#issuecomment-1190132664

   I will use sofa-jraft lib, here is  [Github 
Repository](https://github.com/sofastack/sofa-jraft) and [User 
Guide](https://www.sofastack.tech/en/projects/sofa-jraft/overview/)
   ## sofa-jraft introduction
   
   SOFAJRAFT is a production-grade java implementation of RAFT consensus 
algorithm. SOFAJRaft is licensed under the [Apache License 
2.0](https://github.com/sofastack/sofa-jraft/blob/master/LICENSE). SOFAJRaft 
relies on some third-party components, and their open source protocol is also 
Apache License 2.0.
   
   The core component is StateMachine and RheaKV .
   
   StateMachine is an implementation of users’ core logic. It calls the 
onApply(Iterator) method to apply log entries that are submitted with 
Node#apply(task) to the business state machine.
   
   RheaKV is a lightweight, distributed, and embedded KV storage library, which 
is included in the JRaft project as a submodule.
   
   ## Ephemeral Node
   All node information is stored in StateMachine's memory, StateMachine 
manages the registration and downtime of nodes, When a new node joins the 
cluster, a heartbeat packet is sent to the leader master,  The last update time 
of the node is recorded and synchronized to all masters。When there is a node 
down, Ephemeral Node Refresh Thread scan records in StateMachine , When the 
last update time differs from the current time by more than a certain amount of 
time, nodes are removed and the removed results are synchronized to other 
masters.
   <img width="509" alt="image" 
src="https://user-images.githubusercontent.com/13765310/179958712-6509b5d9-abde-4d98-adc1-2f2ab642de04.png";>
   
   ## Subscribe/Notify
   The design of Subscribe/Notify is the same with ephemeral node, when leader 
master' StateMachine senses a data change in the server ,  then it will trigger 
the subscribed listener.
   <img width="661" alt="image" 
src="https://user-images.githubusercontent.com/13765310/179921155-41ef98fe-1ce6-4e83-b174-893069e24cc4.png";>
   
   
   ## Global Lock
   The design of global lock is the same with ephemeral node, there will be a 
KVStore in the StateMachine to store the lock info.  RheaKVStore will store the 
lock of master server and clear the expiry lock.
   <img width="554" alt="image" 
src="https://user-images.githubusercontent.com/13765310/179961388-d02d1a33-2bf0-4321-b1c6-99465d31d8ae.png";>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to