[ 
https://issues.apache.org/jira/browse/CURATOR-544?focusedWorklogId=431541&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-431541
 ]

ASF GitHub Bot logged work on CURATOR-544:
------------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/May/20 02:32
            Start Date: 07/May/20 02:32
    Worklog Time Spent: 10m 
      Work Description: Randgalt commented on a change in pull request #363:
URL: https://github.com/apache/curator/pull/363#discussion_r421203375



##########
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:
       Yes for sure




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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 431541)
    Time Spent: 50m  (was: 40m)

> Implement SessionFailedRetryPolicy
> ----------------------------------
>
>                 Key: CURATOR-544
>                 URL: https://issues.apache.org/jira/browse/CURATOR-544
>             Project: Apache Curator
>          Issue Type: New Feature
>          Components: Client
>            Reporter: Zili Chen
>            Priority: Major
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> [https://lists.apache.org/x/thread.html/2549c310c1e3232d2f746bf1cf7110c094ea2ca9d1e54b34b75a508f@%3Cuser.curator.apache.org%3E]
> Currently Curator will always reset on session expire and instance a new ZK 
> client as well as recover state.
> Because on session expire ephemeral znodes get deleted, some of user cases 
> possibly want to manually handle session expire before automatically reset 
> {{o.a.c.ConnectionState}}.
> -I propose implement a {{SessionConnectionHandlingPolicy}} whose 
> {{callWithRetry}} use {{SessionFailRetryLoop}} so that 
> {{o.a.c.ConnectionState}} fails on session expired.-
> -BTW, it would be a user-friendly way to make user of 
> {{SessionFailRetryLoop}}.-
> I volunteer to work on an implementation.
> What do you think?
> CC [~randgalt]
> As time goes by, we change a bit what API looks like. For implement the same 
> functionality, we change code of RetryPolicy instead. To be brief, we (1) 
> move {{RetryLook.isRetriableException}} to 
> {{RetryPolicy#allowRetry(Exception)}} and existing impls have a default impl 
> that keeps the manner (2) impl a {{SessionFailedRetryPolicy}} that throws 
> when {{SessionExipredException}} tested, while the other examination 
> delegated to another policy.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to