You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hugegraph.apache.org by "javeme (via GitHub)" <gi...@apache.org> on 2023/02/16 12:53:46 UTC

[GitHub] [incubator-hugegraph] javeme commented on a diff in pull request #2112: fix: transfer add_peer/remove_peer command to leader

javeme commented on code in PR #2112:
URL: https://github.com/apache/incubator-hugegraph/pull/2112#discussion_r1108435191


##########
hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/RaftGroupManagerImpl.java:
##########
@@ -133,16 +143,20 @@ public String addPeer(String endpoint) {
 
     @Override
     public String removePeer(String endpoint) {
-        E.checkArgument(this.raftNode.selfIsLeader(),
-                        "Operation add_peer can only be executed on leader");
         PeerId peerId = PeerId.parsePeer(endpoint);
-        RaftClosure<?> future = new RaftClosure<>();
         try {
-            this.raftNode.node().removePeer(peerId, future);
+            RaftClosure<?> future = new RaftClosure<>();
+            if (this.raftNode.selfIsLeader()) {
+                this.raftNode.node().removePeer(peerId, future);
+            } else {
+                RemovePeerRequest request = RemovePeerRequest.newBuilder()
+                    .setEndpoint(endpoint)

Review Comment:
   prefer to align with `.newBuilder`



-- 
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@hugegraph.apache.org

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