mxsm commented on issue #5745:
URL: https://github.com/apache/rocketmq/issues/5745#issuecomment-1367041974

   #### EN
   
   After the Broker starts, the bound IP address is persisted to the local for 
the next start to compare with the bound address to determine if the IP address 
has changed. At the same time, the two IP addresses are sent to the Controller 
to execute the subsequent master selection logic to solve the problem of unable 
to re-elect the Broker Master due to address change. The specific steps are as 
follows:
   
   1. The Broker starts and loads the IP address persisted locally from the 
last start (the IP address is empty for the first start).
   2. Send a RequestCode.CONTROLLER_REGISTER_BROKER request to the Controller, 
and add an "oldBrokerAddress" field in the 
RegisterBrokerToControllerRequestHeader, which is used to mark the IP address 
persisted locally during the last start.
   3. After the Controller receives the RequestCode.CONTROLLER_REGISTER_BROKER 
request, it determines the execution logic by comparing the oldBrokerAddress 
and brokerAddress.
   4. If the oldBrokerAddress is the same as the brokerAddress or the 
oldBrokerAddress is empty (first start), execute the existing logic.
   5. If the oldBrokerAddress is different from the brokerAddress, use the 
oldBrokerAddress to get the original SyncStateInfo information and BrokerInfo 
election operation.
   6. Add the UpdateBrokerAddressEvent event, replacing the data in the 
oldBrokerAddress related to the state machine with the new brokerAddress 
information.
   7. Return the result to the Broker. If the result is successful, persist the 
current IP address locally, if not successful, do not persist until the normal 
registration is completed and persist again.
   
   
   
   #### 中文
   
   
Broker启动后的绑定IP地址持久化到本地提供给下一次启动时候时候绑定的地址作对比来判断是否IP地址发生变化。同时将两个IP地址发送到Controller来执行后续的选主逻辑从而解决因为地址改变不能重新选举Broker
 Master的问题。具体步骤如下:
   
   1. Broker启动,从本地文件中加载上一次持久化的IP地址(第一次启动IP地址为空)
   2. 
发送RequestCode.CONTROLLER_REGISTER_BROKER请求到Controller,RegisterBrokerToControllerRequestHeader增加oldBrokerAddress字段,这个字段用来标记前一次启动时候持久化在本地IP地址。
   3. 
Controller收到RequestCode.CONTROLLER_REGISTER_BROKER的请求后通过判断oldBrokerAddress与brokerAddress是否相同来决定执行逻辑。
   4. oldBrokerAddress与brokerAddress相同或者oldBrokerAddress为空(第一次启动)执行现有逻辑。
   5. 
oldBrokerAddress与brokerAddress不同,用oldBrokerAddress获取原有的SyncStateInfo信息和BrokerInfo选举操作。
   6. 
增加UpdateBrokerAddressEvent事件,将状态机中的oldBrokerAddress相关的数据替换成新的brokerAddress的信息
   7. 返回结果给Broker,如果结果为成功就将现在IP地址持久化到本地,不成功就不持久化知道能够正常注册完成再次进行持久化。
   
   
![image](https://user-images.githubusercontent.com/15797831/209897806-b66f3e33-dd8c-4128-ab9a-582c4a705c30.png)
   
   @RongtongJin @hzh0425 @tsunghanjacktsai @TheR1sing3un 
   


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