133tosakarin commented on code in PR #13178:
URL: https://github.com/apache/iotdb/pull/13178#discussion_r1719316183


##########
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisClient.java:
##########
@@ -167,4 +210,48 @@ public Action handleAttemptFailure(Event event) {
       return defaultPolicy.handleAttemptFailure(event);
     }
   }
+
+  // This policy is used to raft configuration change
+  private static class RatisEndlessRetryPolicy implements RetryPolicy {
+
+    private static final Logger logger = 
LoggerFactory.getLogger(RatisEndlessRetryPolicy.class);
+    private static final RetryPolicy defaultPolicy;
+
+    static {
+      String str = "";
+      // 50, 500ms, 40, 1000ms, 30, 1500ms, 20, 2000ms, 10, 2500ms
+      int basicRetry = 50;
+      int basicSleep = 500;
+      for (int i = 0; i < 5; i++) {
+        str += basicRetry + "," + basicSleep + ",";
+        basicRetry -= 10;
+        basicSleep += 500;
+      }
+
+      defaultPolicy =
+          MultipleLinearRandomRetry.parseCommaSeparated(str.substring(0, 
str.length() - 1));
+    }
+
+    RatisEndlessRetryPolicy() {}
+
+    @Override
+    public Action handleAttemptFailure(Event event) {
+      // Ratis guarantees that event.getCause() is instance of IOException.
+      // We should allow RaftException or IOException(StatusRuntimeException, 
thrown by gRPC) to be
+      // retried.
+      Optional<Throwable> unexpectedCause =
+          Optional.ofNullable(event.getCause())
+              .filter(RaftException.class::isInstance)
+              .map(Throwable::getCause)
+              .filter(StatusRuntimeException.class::isInstance);

Review Comment:
   I copy from RatisRetryPolicy



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to