You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/08/11 08:59:24 UTC

[GitHub] [rocketmq] mxsm commented on a diff in pull request #4809: feat(controller): add elect policy

mxsm commented on code in PR #4809:
URL: https://github.com/apache/rocketmq/pull/4809#discussion_r943250680


##########
controller/src/main/java/org/apache/rocketmq/controller/elect/ElectPolicy.java:
##########
@@ -0,0 +1,47 @@
+/*
+ * 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.elect;
+
+import org.apache.rocketmq.controller.pojo.BrokerLiveInfo;
+
+import java.util.Set;
+import java.util.function.BiFunction;
+import java.util.function.BiPredicate;
+
+public abstract class ElectPolicy {

Review Comment:
   It would be better to define as interface and add a getElectPolicyType(), It is convenient to expand new election strategies in the future。



##########
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java:
##########
@@ -1685,7 +1685,9 @@ protected void sendHeartbeat() {
                         this.brokerConfig.getBrokerName(),
                         this.brokerConfig.getBrokerId(),
                         this.brokerConfig.getSendHeartbeatTimeoutMillis(),
-                        this.brokerConfig.isInBrokerContainer()
+                        this.brokerConfig.isInBrokerContainer(),
+                            this.replicasManager.getLastEpoch(),
+                            this.messageStore.getMaxPhyOffset()

Review Comment:
   code formate



##########
common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/BrokerHeartbeatRequestHeader.java:
##########
@@ -28,7 +28,10 @@ public class BrokerHeartbeatRequestHeader implements CommandCustomHeader {
     private String brokerAddr;
     @CFNotNull
     private String brokerName;
-
+    @CFNotNull
+    private int epoch;
+    @CFNotNull
+    private long maxOffset;

Review Comment:
   epoch and maxOffset if you want to add @CFNotNull annotation suggest change the type to Integer and Long



##########
controller/src/main/java/org/apache/rocketmq/controller/elect/impl/DefaultElectPolicy.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.elect.impl;
+
+import io.netty.util.internal.StringUtil;

Review Comment:
   Invalid imports need to be removed



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org