TheR1sing3un opened a new issue, #5045:
URL: https://github.com/apache/rocketmq/issues/5045

   # Refactor the register and elect master process in controller mode
   
   ## 背景 BackGround
   
   
现在的注册逻辑也就是在RegisterBrokerToController中包含了分配brokerId以及判断当前是否有master存在,如果没有master存在则也在本次register中添加一个ElectMasterEvent。
   为了之后的持久化brokerId的逻辑,现在需要先将这个register语意拆分,保证register只用于brokerId的获取,而不涉及选举。
   The current registration logic includes the allocation in the brokerId and 
determines whether a master exists, If no master exists, a ElectMasterEvent is 
added to this register.  For the subsequent persistence brokerId logic, we need 
to split the register process first to ensure that the register is only used to 
obtain brokerId and does not involve elections.
   
   > ReplicasInfoManager#registerBroker
   
![image](https://user-images.githubusercontent.com/87409330/189490291-bacc2241-0d17-4c10-850b-0bf468dce79d.png)
   
   并且在broker侧拉取replicasInfo时,当检测到当前没有master,也会使用register去触发controller选举。
   When pulling replicasInfo on the broker side, when no master is detected, 
register is also used to trigger controller election.
   
   > ReplicasManager#schedulingSyncBrokerMetadata
   
   
![image](https://user-images.githubusercontent.com/87409330/189490300-9a778de0-e850-4c88-b57d-fee8df5a958e.png)
   
   
   ---
   
   ## 改造方案 Improvements plan
   
   
在register逻辑中取消触发选举的点,register仅用于brokerId的获取,而broker侧触发controller选举则通过tryElectMaster来实现。
   
   1. 删除controller侧register流程中的选举相关逻辑。
   1. 增加broker侧在register成功之后发送一个tryElectMaster请求到controller,用于触发选举。
   1. 在获取replicasInfo时,感知到此时没有master,则发送tryElectMaster命令尝试选举。
   
   In the register logic, the point that triggers the election is canceled. 
register is only used to obtain the brokerId, while the broker side triggers 
the controller election through the tryElectMaster.
   
   1. Delete the election-related logic in the controller-side register process.
   1. Add a request in the broker side to send a tryElectMaster request to the 
controller after the registering is successful to trigger the election.
   1. When obtaining the replicasInfo, the system detects that there is no 
master at this time, and then sends the tryElectMaster command to try the 
election.


-- 
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