Class TryLoopState<R>

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class TryLoopState<R>
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Retry-logic for attempts for compare-and-swap-like operations.
    • Method Detail

      • newTryLoopState

        public static <R> TryLoopState<R> newTryLoopState​(java.lang.String opName,
                                                          java.util.function.Function<TryLoopState<R>,​java.lang.String> retryErrorMessage,
                                                          java.util.function.BiConsumer<java.lang.Boolean,​TryLoopState<R>> completionNotifier,
                                                          DatabaseAdapterConfig config)
      • getRetries

        public int getRetries()
      • getEndlessRetries

        public int getEndlessRetries()
      • getTotalRetries

        public int getTotalRetries()
      • getDuration

        public long getDuration​(java.util.concurrent.TimeUnit timeUnit)
      • success

        public R success​(R result)
        Called when the operation succeeded. The current implementation is rather a no-op, but can be used to track/trace/monitor successes.
      • retry

        public void retry()
                   throws org.projectnessie.versioned.ReferenceRetryFailureException
        Called when a database-adapter operation needs to retry due to a concurrent-modification / CAS failure.

        If this method just returns, the called can safely retry. If this method throws a ReferenceRetryFailureException, the total time and/or maximum allowed number of retries exceeded the configured values.

        Throws:
        org.projectnessie.versioned.ReferenceRetryFailureException
      • resetBounds

        public void resetBounds()
      • retryEndless

        public void retryEndless()
                          throws org.projectnessie.versioned.ReferenceRetryFailureException
        Similar to retry(), but never throws a ReferenceRetryFailureException (unless a preceding call to retry() already raised it).
        Throws:
        org.projectnessie.versioned.ReferenceRetryFailureException
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable