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/09/14 09:09:45 UTC

[GitHub] [iotdb] SzyWilliam commented on a diff in pull request #7303: [IOTDB-4403] Add retry interface for IStateMachine

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


##########
consensus/src/main/java/org/apache/iotdb/consensus/IStateMachine.java:
##########
@@ -92,6 +92,38 @@ default List<Path> getSnapshotFiles(File latestSnapshotRootDir) {
     return Utils.listAllRegularFilesRecursively(latestSnapshotRootDir);
   }
 
+  /**
+   * To guarantee the statemachine replication property, when {@link #write(IConsensusRequest)}
+   * failed in this statemachine, Upper consensus implementation like RatisConsensus may choose to
+   * retry the operation until it exceeds.
+   */
+  interface RetryPolicy {
+
+    /** Given the last write result, should we retry? */
+    default boolean shouldRetry(TSStatus writeResult) {
+      return false;
+    }
+
+    /**
+     * Use the latest write result to update final write result
+     *
+     * @param retryResult the latest write result
+     * @return the aggregated result upon current retry
+     */
+    default TSStatus updateResult(TSStatus retryResult) {
+      return retryResult;
+    }
+
+    /**
+     * sleep time before the next retry
+     *
+     * @return time in millis
+     */
+    default long getSleepTime() {
+      return 0;

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