You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@curator.apache.org by GitBox <gi...@apache.org> on 2020/05/07 12:01:06 UTC

[GitHub] [curator] TisonKun commented on a change in pull request #363: CURATOR-544: SessionFailedRetryPolicy

TisonKun commented on a change in pull request #363:
URL: https://github.com/apache/curator/pull/363#discussion_r421449573



##########
File path: curator-client/src/main/java/org/apache/curator/RetryPolicy.java
##########
@@ -33,5 +35,26 @@
      * @param sleeper use this to sleep - DO NOT call Thread.sleep
      * @return true/false
      */
-    public boolean      allowRetry(int retryCount, long elapsedTimeMs, RetrySleeper sleeper);
+    boolean allowRetry(int retryCount, long elapsedTimeMs, RetrySleeper sleeper);
+
+    /**
+     * Called when an operation has failed with a specific exception. This method
+     * should return true to make another attempt.
+     *
+     * @param exception the cause that this operation failed
+     * @return true/false
+     */
+    default boolean allowRetry(Throwable exception)
+    {
+        if ( exception instanceof KeeperException)
+        {
+            final int rc = ((KeeperException) exception).code().intValue();
+            return (rc == KeeperException.Code.CONNECTIONLOSS.intValue()) ||
+                    (rc == KeeperException.Code.OPERATIONTIMEOUT.intValue()) ||
+                    (rc == KeeperException.Code.SESSIONMOVED.intValue()) ||
+                    (rc == KeeperException.Code.SESSIONEXPIRED.intValue()) ||
+                    (rc == -13); // KeeperException.Code.NEWCONFIGNOQUORUM.intValue()) - using hard coded value for ZK 3.4.x compatibility

Review comment:
       Thanks for spotting this. Will update.




----------------------------------------------------------------
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.

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