You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/08/17 01:43:10 UTC

[GitHub] [iotdb] SzyWilliam commented on a diff in pull request #7002: [IOTDB-4138] Refactor consensus api and add javadoc

SzyWilliam commented on code in PR #7002:
URL: https://github.com/apache/iotdb/pull/7002#discussion_r947377307


##########
consensus/src/main/java/org/apache/iotdb/consensus/IConsensus.java:
##########
@@ -44,15 +44,61 @@ public interface IConsensus {
   ConsensusReadResponse read(ConsensusGroupId groupId, IConsensusRequest IConsensusRequest);
 
   // multi consensus group API
-  ConsensusGenericResponse addConsensusGroup(ConsensusGroupId groupId, List<Peer> peers);
 
-  ConsensusGenericResponse removeConsensusGroup(ConsensusGroupId groupId);
+  /**
+   * Require the <em>local node</em> to create a Peer and become a member of the given consensus
+   * group. This node will prepare and initialize local statemachine {@link IStateMachine} and other
+   * data structures. After this method returns, we can call {@link #addPeer(ConsensusGroupId,
+   * Peer)} to notify original group that this new Peer is prepared to be added into the latest
+   * configuration.
+   *
+   * @param groupId the consensus group this Peer belongs
+   * @param peers other known peers in this group
+   */
+  ConsensusGenericResponse createPeer(ConsensusGroupId groupId, List<Peer> peers);
+
+  /**
+   * When the <em>local node</em> is no longer a member of the given consensus group, call this
+   * method to do cleanup works. This method will close local statemachine {@link IStateMachine},
+   * delete local data and do other cleanup works. Be sure this method is called after successfully
+   * removing local peer from current consensus group configuration (by calling {@link
+   * #removePeer(ConsensusGroupId, Peer)} or {@link #changePeer(ConsensusGroupId, List)}).
+   *
+   * @param groupId the consensus group this Peer used to belong
+   */
+  ConsensusGenericResponse deletePeer(ConsensusGroupId groupId);
 
   // single consensus group API
+
+  /**
+   * Tell the group that a new Peer is prepared to be added into this group. Call {@link
+   * #createPeer(ConsensusGroupId, List)} on the new Peer before calling this method. When this
+   * method returns, the group data should be already transmitted to the new Peer. That is, the new
+   * peer is available to answer client requests by the time this method successfully returns.
+   *
+   * @param groupId the consensus group this peer belongs
+   * @param peer the newly added peer
+   */
   ConsensusGenericResponse addPeer(ConsensusGroupId groupId, Peer peer);
 
+  /**
+   * Tell the group to remove an active Peer. The removed peer can no longer answer group requests
+   * when this method successfully returns. Call {@link #deletePeer(ConsensusGroupId)} on the
+   * removed Peer to do cleanup jobs after this method successfully returns.
+   *
+   * @param groupId the consensus group this peer belongs
+   * @param peer the peer to be removed
+   */
   ConsensusGenericResponse removePeer(ConsensusGroupId groupId, Peer peer);

Review Comment:
   done



##########
consensus/src/main/java/org/apache/iotdb/consensus/IConsensus.java:
##########
@@ -44,15 +44,61 @@ public interface IConsensus {
   ConsensusReadResponse read(ConsensusGroupId groupId, IConsensusRequest IConsensusRequest);
 
   // multi consensus group API
-  ConsensusGenericResponse addConsensusGroup(ConsensusGroupId groupId, List<Peer> peers);
 
-  ConsensusGenericResponse removeConsensusGroup(ConsensusGroupId groupId);
+  /**
+   * Require the <em>local node</em> to create a Peer and become a member of the given consensus
+   * group. This node will prepare and initialize local statemachine {@link IStateMachine} and other
+   * data structures. After this method returns, we can call {@link #addPeer(ConsensusGroupId,
+   * Peer)} to notify original group that this new Peer is prepared to be added into the latest
+   * configuration.
+   *
+   * @param groupId the consensus group this Peer belongs
+   * @param peers other known peers in this group
+   */
+  ConsensusGenericResponse createPeer(ConsensusGroupId groupId, List<Peer> peers);
+
+  /**
+   * When the <em>local node</em> is no longer a member of the given consensus group, call this
+   * method to do cleanup works. This method will close local statemachine {@link IStateMachine},
+   * delete local data and do other cleanup works. Be sure this method is called after successfully
+   * removing local peer from current consensus group configuration (by calling {@link
+   * #removePeer(ConsensusGroupId, Peer)} or {@link #changePeer(ConsensusGroupId, List)}).
+   *
+   * @param groupId the consensus group this Peer used to belong
+   */
+  ConsensusGenericResponse deletePeer(ConsensusGroupId groupId);
 
   // single consensus group API
+
+  /**
+   * Tell the group that a new Peer is prepared to be added into this group. Call {@link
+   * #createPeer(ConsensusGroupId, List)} on the new Peer before calling this method. When this
+   * method returns, the group data should be already transmitted to the new Peer. That is, the new
+   * peer is available to answer client requests by the time this method successfully returns.
+   *
+   * @param groupId the consensus group this peer belongs
+   * @param peer the newly added peer
+   */
   ConsensusGenericResponse addPeer(ConsensusGroupId groupId, Peer peer);

Review Comment:
   done



-- 
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: reviews-unsubscribe@iotdb.apache.org

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