public SessionFailRetryLoop(CuratorZookeeperClient client, Mode _mode)
        {
            watcher = new tempWatcher <bool>(() => {
                sessionHasFailed = true;
                failedSessionThreads.GetOrAdd(ourThread, false);
                return(true);
            });


            this.client = client;
            mode        = _mode;
            retryLoop   = client.NewRetryLoop();
        }
Example #2
0
        /**
         * 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, Func <T> proc)
        {
            T         result    = default(T);
            RetryLoop retryLoop = client.NewRetryLoop();

            while (retryLoop.ShouldContinue())
            {
                try
                {
                    client.InternalBlockUntilConnectedOrTimedOut();

                    result = proc();
                    retryLoop.MarkComplete();
                }
                catch (Exception e)
                {
                    retryLoop.TakeException(e);
                }
            }
            return(result);
        }