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


##########
controller/src/main/java/org/apache/rocketmq/controller/impl/manager/ReplicasInfoManager.java:
##########
@@ -150,52 +153,42 @@ public ControllerResult<AlterSyncStateSetResponseHeader> 
alterSyncStateSet(
         return result;
     }
 
-    public ControllerResult<ElectMasterResponseHeader> electMaster(
-            final ElectMasterRequestHeader request, final BiPredicate<String, 
String> brokerAlivePredicate) {
+    public ControllerResult<ElectMasterResponseHeader> electMaster(final 
ElectMasterRequestHeader request, final ElectPolicy electPolicy) {
         final String brokerName = request.getBrokerName();
         final String assignBrokerAddress = request.getBrokerAddress();
         final ControllerResult<ElectMasterResponseHeader> result = new 
ControllerResult<>(new ElectMasterResponseHeader());
         if (isContainsBroker(brokerName)) {
             final SyncStateInfo syncStateInfo = 
this.syncStateSetInfoTable.get(brokerName);
             final BrokerInfo brokerInfo = 
this.replicaInfoTable.get(brokerName);
             final Set<String> syncStateSet = syncStateInfo.getSyncStateSet();
-            // First, check whether the master is still active
             final String oldMaster = syncStateInfo.getMasterAddress();
-            if (StringUtils.isNoneEmpty(oldMaster) && 
brokerAlivePredicate.test(brokerInfo.getClusterName(), oldMaster)) {
+            Set<String> allReplicaBrokers = 
controllerConfig.isEnableElectUncleanMaster() ? brokerInfo.getAllBroker() : 
null;
 
-                if (StringUtils.isBlank(assignBrokerAddress)) {
-                    String err = String.format("The old master %s is still 
alive, no need to elect new master for broker %s", oldMaster, 
brokerInfo.getBrokerName());
-                    log.warn("{}", err);
-                    
result.setCodeAndRemark(ResponseCode.CONTROLLER_INVALID_REQUEST, err);
-                    return result;
-                }
-
-                if (StringUtils.equals(oldMaster, assignBrokerAddress)) {
-                    String err = String.format("The Re-elect master is the 
same as the old master %s which is still alive, no need to elect new master for 
broker %s", oldMaster, brokerInfo.getBrokerName());
-                    log.warn("{}", err);
-                    
result.setCodeAndRemark(ResponseCode.CONTROLLER_INVALID_REQUEST, err);
-                    return result;
-                }
-            }
-
-            // Try elect a master in syncStateSet
-            if (syncStateSet.size() > 1) {
-                boolean electSuccess = tryElectMaster(result, brokerName, 
assignBrokerAddress, syncStateSet, candidate ->
-                        !candidate.equals(syncStateInfo.getMasterAddress()) && 
brokerAlivePredicate.test(brokerInfo.getClusterName(), candidate));
-                if (electSuccess) {
-                    return result;
-                }
+            // elect by policy

Review Comment:
   Discarding the process of assginBrokerAddress will cause the function of 
[ReElectMasterSubCommand](https://github.com/apache/rocketmq/pull/4798) to fail



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