internal SessionFailRetryLoop(CuratorZookeeperClient client, Mode mode) { this.client = client; this.mode = mode; retryLoop = client.newRetryLoop(); watcher = new SessionFailWatcher(this); }
/** * Convenience utility: creates a retry loop calling the given proc and retrying if needed * * @param client Zookeeper * @param proc procedure to call with retry * @param <T> return type * @return procedure result * @throws Exception any non-retriable errors */ public static T callWithRetry <T>(CuratorZookeeperClient client, ICallable <T> proc) { T result = default(T); RetryLoop retryLoop = client.newRetryLoop(); while (retryLoop.shouldContinue()) { try { client.internalBlockUntilConnectedOrTimedOut(); result = proc.call(); retryLoop.markComplete(); } catch (Exception e) { ThreadUtils.checkInterrupted(e); retryLoop.takeException(e); } } return(result); }