Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

选举的Leader问题 #2

Open
jetamie opened this issue Nov 20, 2019 · 2 comments
Open

选举的Leader问题 #2

jetamie opened this issue Nov 20, 2019 · 2 comments

Comments

@jetamie
Copy link

jetamie commented Nov 20, 2019

如果选取的Leader的机器发生故障,可以重新选取Leader吗,有具体过程吗,谢谢

@busgo
Copy link
Owner

busgo commented Nov 21, 2019

如果选取的Leader的机器发生故障,可以重新选取Leader吗,有具体过程吗,谢谢

Leader的机器发生故障会重新选择出一个新的Leader

  1. 所有节点启动时都监听/forest/server/elect/leader是否发生变更。
  2. 如果发生变更则不断自己尝试创建属于自己的/forest/server/elect/leader(内容为自己的node id)也就是自己竞选Leader请求(注意使用etcd租约以及事务仅有一个节点创建成功)。
  3. 如果当前节点竞选失败,发现已经有新的Leader产生则自己放弃竞选,等待下一个Leader失效再次参与竞选。
  4. 如果竞选Leader成功则开始刷新当前任务配置与任务执行计划同步工作,并根据任务执行计划计划式派发任务和收集统计任务执行状态。

所有节点都是对等的只有Leader才有权限派发任务

具体可以源码参考

  1. Leader节点变更监听

  2. 不断尝试发起选举请求

  3. 节点状态变更通知

如果有其他不明白的地方请多多指导,谢谢!

@busgo
Copy link
Owner

busgo commented Nov 21, 2019

@jetamie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants