RongtongJin commented on code in PR #6100:
URL: https://github.com/apache/rocketmq/pull/6100#discussion_r1112738675
##########
remoting/src/main/java/org/apache/rocketmq/remoting/protocol/header/namesrv/BrokerHeartbeatRequestHeader.java:
##########
@@ -29,7 +29,7 @@ public class BrokerHeartbeatRequestHeader implements
CommandCustomHeader {
private String brokerAddr;
@CFNotNull
private String brokerName;
- @CFNullable
+ @CFNotNull
Review Comment:
BrokerHeartbeatRequestHeader在controller中被用到,在Broker发给nameserver的轻量级心跳中也被用到(详见[RIP-32](https://github.com/apache/rocketmq/wiki/RIP-32-Slave-Acting-Master-Mode)),为了保持兼容性,建议仍然是CFNullable,在controller处对没有brokerId的进行拦截(提醒用户升级)
##########
tools/src/main/java/org/apache/rocketmq/tools/command/controller/ReElectMasterSubCommand.java:
##########
@@ -45,7 +46,7 @@ public Options buildCommandlineOptions(Options options) {
opt.setRequired(true);
options.addOption(opt);
- opt = new Option("b", "brokerAddress", true, "The address of the
broker which requires to become master");
Review Comment:
保持brokerAddress是不是更易使用?或者我们需要一个命令来获取所有的地址与brokerId的对应关系
##########
controller/src/main/java/org/apache/rocketmq/controller/impl/manager/BrokerReplicaInfo.java:
##########
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.rocketmq.controller.impl.manager;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.Pair;
+
+/**
+ * Broker replicas info, mapping from brokerAddress to {brokerId,
brokerHaAddress}.
+ */
+public class BrokerReplicaInfo {
+ private final String clusterName;
+
+ private final String brokerName;
+
+ // Start from 1
+ private final AtomicLong nextAssignBrokerId;
+
+ private final HashMap<Long/*brokerId*/, Pair<String/*ipAddress*/,
String/*registerCheckCode*/>> brokerIdInfo;
+
+ public BrokerReplicaInfo(String clusterName, String brokerName) {
+ this.clusterName = clusterName;
+ this.brokerName = brokerName;
+ this.nextAssignBrokerId = new AtomicLong(MixAll.FIRST_SLAVE_ID);
Review Comment:
这里用FIRST_SLAVE_ID语义不是很好,这是brokerControlllerId编号,跟slaveId没什么关系
##########
remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RequestCode.java:
##########
@@ -275,5 +275,11 @@ public class RequestCode {
*/
public static final int CLEAN_BROKER_DATA = 1011;
+ public static final int GET_NEXT_BROKER_ID = 1012;
+
+ public static final int APPLY_BROKER_ID = 1013;
+
+ public static final int REGISTER_SUCCESS = 1014;
Review Comment:
1.建议RequestCode前都增加一个CONTROLLER_的前缀
2.REGISTER_SUCCESS能不能不新增,用之前的CONTROLLER_REGISTER_BROKER
##########
broker/src/main/java/org/apache/rocketmq/broker/controller/ReplicasManager.java:
##########
@@ -77,10 +82,20 @@ public class ReplicasManager {
private volatile String controllerLeaderAddress = "";
private volatile State state = State.INITIAL;
+ private RegisterState registerState = RegisterState.INITIAL;
+
private ScheduledFuture<?> checkSyncStateSetTaskFuture;
private ScheduledFuture<?> slaveSyncFuture;
- private Set<String> syncStateSet;
+ private Long brokerId;
Review Comment:
要不叫brokerControllerId,与brokerId做一个区分。
--
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]