Class TryLoopState
- java.lang.Object
-
- org.projectnessie.versioned.persist.adapter.spi.TryLoopState
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class TryLoopState extends java.lang.Object implements java.lang.AutoCloseableRetry-logic for attempts for compare-and-swap-like operations.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()longgetDuration(java.util.concurrent.TimeUnit timeUnit)intgetEndlessRetries()intgetRetries()intgetTotalRetries()static TryLoopStatenewTryLoopState(java.lang.String opName, java.util.function.Function<TryLoopState,java.lang.String> retryErrorMessage, java.util.function.BiConsumer<java.lang.Boolean,TryLoopState> completionNotifier, DatabaseAdapterConfig config)voidresetBounds()voidretry()Called when a database-adapter operation needs to retry due to a concurrent-modification / CAS failure.voidretryEndless()org.projectnessie.versioned.Hashsuccess(org.projectnessie.versioned.Hash result)Called when the operation succeeded.
-
-
-
Method Detail
-
newTryLoopState
public static TryLoopState newTryLoopState(java.lang.String opName, java.util.function.Function<TryLoopState,java.lang.String> retryErrorMessage, java.util.function.BiConsumer<java.lang.Boolean,TryLoopState> 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 org.projectnessie.versioned.Hash success(org.projectnessie.versioned.Hash 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.ReferenceRetryFailureExceptionCalled 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, thetotal timeand/or maximumallowed number of retriesexceeded the configured values.- Throws:
org.projectnessie.versioned.ReferenceRetryFailureException
-
resetBounds
public void resetBounds()
-
retryEndless
public void retryEndless() throws org.projectnessie.versioned.ReferenceRetryFailureExceptionSimilar toretry(), but never throws aReferenceRetryFailureException(unless a preceding call toretry()already raised it).- Throws:
org.projectnessie.versioned.ReferenceRetryFailureException
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
-