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/15 15:37:35 UTC

[GitHub] [rocketmq] mxsm commented on a diff in pull request #4823: [ISSUE #4817] Add a command to clear broker data from controller for CLI

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


##########
controller/src/main/java/org/apache/rocketmq/controller/impl/DLedgerController.java:
##########
@@ -193,6 +194,32 @@ public RemotingServer getRemotingServer() {
         return this.dLedgerServer.getRemotingServer();
     }
 
+    @Override
+    public CompletableFuture<RemotingCommand> cleanBrokerData(
+        final CleanControllerBrokerDataRequestHeader requestHeader,
+        final BiPredicate<String, String> brokerAlivePredicate) {
+
+        String brokerAddrs = requestHeader.getBrokerAddress();
+        String clusterName = requestHeader.getClusterName();
+        if ((null == brokerAddrs || brokerAddrs.trim().isEmpty()) && brokerAlivePredicate.test(clusterName, null)) {
+            RemotingCommand responseCommand = RemotingCommand.createResponseCommand(ResponseCode.CONTROLLER_INVALID_REQUEST,
+                String.format("Broker %s is still alive, clean up failure", requestHeader.getBrokerName()));
+            return CompletableFuture.completedFuture(responseCommand);
+        } else {
+            String[] brokerAddrArray = brokerAddrs.split(";");
+            for (String brokerAddr : brokerAddrArray) {
+                if (brokerAlivePredicate.test(clusterName, brokerAddr)) {
+                    RemotingCommand responseCommand = RemotingCommand.createResponseCommand(ResponseCode.CONTROLLER_INVALID_REQUEST,
+                        String.format("Broker [%s,  %s] is still alive, clean up failure", requestHeader.getBrokerName(), brokerAddr));
+                    return CompletableFuture.completedFuture(responseCommand);
+                }
+            }
+        }

Review Comment:
   I will moving these to replicasInfoManager 



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