RongtongJin commented on code in PR #4341:
URL: https://github.com/apache/rocketmq/pull/4341#discussion_r877792429


##########
common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java:
##########
@@ -293,10 +293,24 @@ public class BrokerConfig extends BrokerIdentity {
      */
     private boolean lockInStrictMode = false;
 
-    private String controllerAddr = "";
-
     private boolean compatibleWithOldNameSrv = true;
 
+    /**
+     * Is startup controller mode, which support auto switch broker's role.
+     */
+    private boolean startupControllerMode = false;
+
+    /**
+     * Whether the controller is deployed independently
+     */
+    private boolean isControllerDeployedStandAlone = false;
+
+    /**
+     * If isControllerDeployedStandAlone = false, controllerAddr should be 
equal to namesrv's address.

Review Comment:
   改下注释吧,Controller内嵌入nameserver时,controllerAddr不需要和namesever地址完全一致



##########
broker/src/main/java/org/apache/rocketmq/broker/hacontroller/ReplicasManager.java:
##########
@@ -235,18 +273,26 @@ private boolean registerBroker() {
     private void schedulingSyncBrokerMetadata() {
         this.scheduledService.scheduleAtFixedRate(() -> {
             try {
-                final Pair<GetReplicaInfoResponseHeader, SyncStateSet> result 
= this.brokerOuterAPI.getReplicaInfo(this.controllerLeaderAddress, 
this.brokerConfig.getBrokerName());
+                final Pair<GetReplicaInfoResponseHeader, SyncStateSet> result 
= this.brokerOuterAPI.getReplicaInfo(this.controllerLeaderAddress, 
this.brokerConfig.getBrokerName(), this.localAddress);
                 final GetReplicaInfoResponseHeader info = result.getObject1();
                 final SyncStateSet syncStateSet = result.getObject2();
                 final String newMasterAddress = info.getMasterAddress();
                 final int newMasterEpoch = info.getMasterEpoch();
+                final long brokerId = info.getBrokerId();
                 synchronized (this) {
                     // Check if master changed
                     if (StringUtils.isNoneEmpty(newMasterAddress) && 
!StringUtils.equals(this.masterAddress, newMasterAddress) && newMasterEpoch > 
this.masterEpoch) {
                         if (StringUtils.equals(newMasterAddress, 
this.localAddress)) {
                             changeToMaster(newMasterEpoch, 
syncStateSet.getSyncStateSetEpoch());
                         } else {
                             changeToSlave(newMasterAddress, newMasterEpoch);

Review Comment:
   changeToSlave了两次,可以把brokerId传入changeToSlave,在里面有修改brokerId,和changeToMaster一样



##########
broker/src/main/java/org/apache/rocketmq/broker/hacontroller/ReplicasManager.java:
##########
@@ -354,4 +400,8 @@ public String getMasterAddress() {
     public int getMasterEpoch() {
         return masterEpoch;
     }
+
+    public List<String> getControllerAddresses() {
+        return new ArrayList<>(this.controllerAddresses);
+    }

Review Comment:
   为什么这里需要重新new一个?



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