You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ca...@apache.org on 2022/10/25 02:51:29 UTC

[iotdb] branch master updated: [IOTDB-4664] add updatePeer interface in IConsensus (#7634)

This is an automated email from the ASF dual-hosted git repository.

caogaofei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new cbc622573f [IOTDB-4664] add updatePeer interface in IConsensus (#7634)
cbc622573f is described below

commit cbc622573fe403b4e91bd576bf5b49156d1c91eb
Author: Itami Sho <42...@users.noreply.github.com>
AuthorDate: Tue Oct 25 10:51:24 2022 +0800

    [IOTDB-4664] add updatePeer interface in IConsensus (#7634)
---
 .../src/main/java/org/apache/iotdb/consensus/IConsensus.java   | 10 ++++++++++
 .../iotdb/consensus/multileader/MultiLeaderConsensus.java      |  5 +++++
 .../java/org/apache/iotdb/consensus/ratis/RatisConsensus.java  |  5 +++++
 .../apache/iotdb/consensus/standalone/StandAloneConsensus.java |  5 +++++
 4 files changed, 25 insertions(+)

diff --git a/consensus/src/main/java/org/apache/iotdb/consensus/IConsensus.java b/consensus/src/main/java/org/apache/iotdb/consensus/IConsensus.java
index be1ab10906..f3a01a02d8 100644
--- a/consensus/src/main/java/org/apache/iotdb/consensus/IConsensus.java
+++ b/consensus/src/main/java/org/apache/iotdb/consensus/IConsensus.java
@@ -96,6 +96,16 @@ public interface IConsensus {
    */
   ConsensusGenericResponse removePeer(ConsensusGroupId groupId, Peer peer);
 
+  /**
+   * Tell the group to update an active Peer. The modifiable part of {@link Peer} is TEndPoint.
+   *
+   * @param groupId the consensus group this peer belongs
+   * @param oldPeer the peer to be updated
+   * @param newPeer the peer to be updated to
+   */
+  // TODO: @SzyWilliam @SpriCoder Please implement this method
+  ConsensusGenericResponse updatePeer(ConsensusGroupId groupId, Peer oldPeer, Peer newPeer);
+
   /**
    * Change group configuration. This method allows you to add/remove multiple Peers at once. This
    * method is similar to {@link #addPeer(ConsensusGroupId, Peer)} or {@link
diff --git a/consensus/src/main/java/org/apache/iotdb/consensus/multileader/MultiLeaderConsensus.java b/consensus/src/main/java/org/apache/iotdb/consensus/multileader/MultiLeaderConsensus.java
index a5a5c9d0d3..fc8039c979 100644
--- a/consensus/src/main/java/org/apache/iotdb/consensus/multileader/MultiLeaderConsensus.java
+++ b/consensus/src/main/java/org/apache/iotdb/consensus/multileader/MultiLeaderConsensus.java
@@ -308,6 +308,11 @@ public class MultiLeaderConsensus implements IConsensus {
     return ConsensusGenericResponse.newBuilder().setSuccess(true).build();
   }
 
+  @Override
+  public ConsensusGenericResponse updatePeer(ConsensusGroupId groupId, Peer oldPeer, Peer newPeer) {
+    return ConsensusGenericResponse.newBuilder().setSuccess(true).build();
+  }
+
   @Override
   public ConsensusGenericResponse changePeer(ConsensusGroupId groupId, List<Peer> newPeers) {
     return ConsensusGenericResponse.newBuilder().setSuccess(false).build();
diff --git a/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java b/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
index 76479cd74c..7d0d78ae0c 100644
--- a/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
+++ b/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
@@ -444,6 +444,11 @@ class RatisConsensus implements IConsensus {
     return ConsensusGenericResponse.newBuilder().setSuccess(reply.isSuccess()).build();
   }
 
+  @Override
+  public ConsensusGenericResponse updatePeer(ConsensusGroupId groupId, Peer oldPeer, Peer newPeer) {
+    return ConsensusGenericResponse.newBuilder().setSuccess(true).build();
+  }
+
   @Override
   public ConsensusGenericResponse changePeer(ConsensusGroupId groupId, List<Peer> newPeers) {
     RaftGroup raftGroup = buildRaftGroup(groupId, newPeers);
diff --git a/consensus/src/main/java/org/apache/iotdb/consensus/standalone/StandAloneConsensus.java b/consensus/src/main/java/org/apache/iotdb/consensus/standalone/StandAloneConsensus.java
index 76bb103bc6..ee00b9021d 100644
--- a/consensus/src/main/java/org/apache/iotdb/consensus/standalone/StandAloneConsensus.java
+++ b/consensus/src/main/java/org/apache/iotdb/consensus/standalone/StandAloneConsensus.java
@@ -204,6 +204,11 @@ class StandAloneConsensus implements IConsensus {
     return ConsensusGenericResponse.newBuilder().setSuccess(false).build();
   }
 
+  @Override
+  public ConsensusGenericResponse updatePeer(ConsensusGroupId groupId, Peer oldPeer, Peer newPeer) {
+    return ConsensusGenericResponse.newBuilder().setSuccess(false).build();
+  }
+
   @Override
   public ConsensusGenericResponse changePeer(ConsensusGroupId groupId, List<Peer> newPeers) {
     return ConsensusGenericResponse.newBuilder().setSuccess(false).build();