Class StmUtils
- java.lang.Object
-
- org.multiverse.api.StmUtils
-
public final class StmUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidabort()Aborts the Transaction in the TxnThreadLocal transaction.static voidatomic(Runnable runnable)static <E> Eatomic(Callable<E> callable)static booleanatomic(TxnBooleanCallable callable)Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.static booleanatomic(TxnBooleanCallable either, TxnBooleanCallable orelse)Executes the either block, or in case of a retry, the orelse block is executed.static <E> Eatomic(TxnCallable<E> callable)Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.static <E> Eatomic(TxnCallable<E> either, TxnCallable<E> orelse)Executes the either block, or in case of a retry, the orelse block is executed.static doubleatomic(TxnDoubleCallable callable)Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.static doubleatomic(TxnDoubleCallable either, TxnDoubleCallable orelse)Executes the either block, or in case of a retry, the orelse block is executed.static intatomic(TxnIntCallable callable)Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.static intatomic(TxnIntCallable either, TxnIntCallable orelse)Executes the either block, or in case of a retry, the orelse block is executed.static longatomic(TxnLongCallable callable)Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.static longatomic(TxnLongCallable either, TxnLongCallable orelse)Executes the either block, or in case of a retry, the orelse block is executed.static voidatomic(TxnVoidCallable callable)Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.static voidatomic(TxnVoidCallable either, TxnVoidCallable orelse)Executes the either block, or in case of a retry, the orelse block is executed.static booleanatomicChecked(TxnBooleanCallable callable)Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.static booleanatomicChecked(TxnBooleanCallable either, TxnBooleanCallable orelse)Executes the either block, or in case of a retry, the orelse block is executed.static <E> EatomicChecked(TxnCallable<E> callable)Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.static <E> EatomicChecked(TxnCallable<E> either, TxnCallable<E> orelse)Executes the either block, or in case of a retry, the orelse block is executed.static doubleatomicChecked(TxnDoubleCallable callable)Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.static doubleatomicChecked(TxnDoubleCallable either, TxnDoubleCallable orelse)Executes the either block, or in case of a retry, the orelse block is executed.static intatomicChecked(TxnIntCallable callable)Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.static intatomicChecked(TxnIntCallable either, TxnIntCallable orelse)Executes the either block, or in case of a retry, the orelse block is executed.static longatomicChecked(TxnLongCallable callable)Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.static longatomicChecked(TxnLongCallable either, TxnLongCallable orelse)Executes the either block, or in case of a retry, the orelse block is executed.static voidatomicChecked(TxnVoidCallable callable)Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.static voidatomicChecked(TxnVoidCallable either, TxnVoidCallable orelse)Executes the either block, or in case of a retry, the orelse block is executed.static voidcommit()Commits the Transaction in the TxnThreadLocal transaction.static TxnBooleannewTxnBoolean()Creates a committedTxnBooleanwith false as initial value using theGlobalStmInstance.static TxnBooleannewTxnBoolean(boolean value)Creates a committedTxnBooleanwith the provided value using theGlobalStmInstance.static <E> TxnDeque<E>newTxnDeque()Creates a new committed unbound TxnDeque.static <E> TxnDeque<E>newTxnDeque(int capacity)Creates a new committed bound TxnDeque.static TxnDoublenewTxnDouble()Creates a committedTxnDoublewith 0 as initial value using theGlobalStmInstance.static TxnDoublenewTxnDouble(double value)Creates a committedTxnDoublewith the provided value using theGlobalStmInstance.static <K,V>
TxnMap<K,V>newTxnHashMap()Creates a new committed TxnMap.static <E> TxnSet<E>newTxnHashSet()Creates a new committed TxnSet that is based on a 'hashtable'.static TxnIntegernewTxnInteger()Creates a committedTxnIntegerwith 0 as initial value using theGlobalStmInstance.static TxnIntegernewTxnInteger(int value)Creates a committedTxnIntegerwith the provided value using theGlobalStmInstance.static <E> TxnList<E>newTxnLinkedList()Creates a new committed TxnList based on a double linked list.static TxnLongnewTxnLong()Creates a committedTxnLongwith 0 as initial value using theGlobalStmInstance.static TxnLongnewTxnLong(long value)Creates a committedTxnLongwith the provided value using theGlobalStmInstance.static <E> TxnQueue<E>newTxnQueue()Creates a new committed unbound TxnQueue.static <E> TxnQueue<E>newTxnQueue(int capacity)Creates a new committed bound TxnQueue.static <E> TxnRef<E>newTxnRef()Creates a committedTxnRefwith null as initial value using theGlobalStmInstance.static <E> TxnRef<E>newTxnRef(E value)Creates a committedTxnRefwith the provided value using theGlobalStmInstance.static <E> TxnStack<E>newTxnStack()Creates a new committed unbound TxnStack.static <E> TxnStack<E>newTxnStack(int capacity)Creates a new committed bound TxnStack.static voidprepare()Prepares the Transaction in the TxnThreadLocal transaction.static voidretry()Does a retry.static voidscheduleCompensatingOrDeferredTask(Runnable task)Scheduled an deferred or compensating task on theTxnin the TxnThreadLocal.static voidscheduleCompensatingTask(Runnable task)Scheduled a compensating task on theTxnin theTxnThreadLocal.static voidscheduleDeferredTask(Runnable task)Scheduled an deferred task on theTxnin theTxnThreadLocal.
-
-
-
Method Detail
-
newTxnLinkedList
public static <E> TxnList<E> newTxnLinkedList()
Creates a new committed TxnList based on a double linked list.- Returns:
- the created TxnList.
-
newTxnStack
public static <E> TxnStack<E> newTxnStack()
Creates a new committed unbound TxnStack.- Returns:
- the created TxnStack.
-
newTxnStack
public static <E> TxnStack<E> newTxnStack(int capacity)
Creates a new committed bound TxnStack.- Parameters:
capacity- the maximum capacity of the stack. Integer.MAX_VALUE indicates that there is no bound.- Returns:
- the create TxnStack
- Throws:
IllegalArgumentException- if capacity smaller than 0.
-
newTxnQueue
public static <E> TxnQueue<E> newTxnQueue()
Creates a new committed unbound TxnQueue.- Returns:
- the created TxnQueue.
-
newTxnQueue
public static <E> TxnQueue<E> newTxnQueue(int capacity)
Creates a new committed bound TxnQueue.- Parameters:
capacity- the maximum capacity of the queue. Integer.MAX_VALUE indicates that there is no bound.- Returns:
- the created TxnQueue
- Throws:
IllegalArgumentException- if capacity smaller than 0.
-
newTxnDeque
public static <E> TxnDeque<E> newTxnDeque()
Creates a new committed unbound TxnDeque.- Returns:
- the created TxnDeque
-
newTxnDeque
public static <E> TxnDeque<E> newTxnDeque(int capacity)
Creates a new committed bound TxnDeque.- Parameters:
capacity- the maximum capacity of the deque. Integer.MAX_VALUE indicates that there is no bound.- Returns:
- the created TxnDeque.
- Throws:
IllegalArgumentException- if capacity is smaller than 0.
-
newTxnHashSet
public static <E> TxnSet<E> newTxnHashSet()
Creates a new committed TxnSet that is based on a 'hashtable'.- Returns:
- the created TxnSet.
-
newTxnHashMap
public static <K,V> TxnMap<K,V> newTxnHashMap()
Creates a new committed TxnMap.- Returns:
- the created TxnMap
-
atomic
public static void atomic(Runnable runnable)
-
atomic
public static <E> E atomic(Callable<E> callable)
-
atomic
public static <E> E atomic(TxnCallable<E> callable)
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor. If a Transaction already is active on the TxnThreadLocal, this transaction will lift on that transaction (so the propagation level is Requires) and will not commit this transaction.This method doesn't throw a checked exception, but if the callable does, it is wrapped inside an InvisibleCheckedException.
If you want to get most out of performance, it is best to make use of a customized
TxnExecutorinstead of relying on the default TxnExecutor that will always provide the most expensive transaction available.- Parameters:
callable- The callableTxnCallableto execute.- Returns:
- the result of the execution
- Throws:
NullPointerException- if callable is null.InvisibleCheckedException- if the callable throws a checked exception.
-
atomicChecked
public static <E> E atomicChecked(TxnCallable<E> callable) throws Exception
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor. If a Transaction already is active on the TxnThreadLocal, this transaction will lift on that transaction (so the propagation level is Requires) and will not commit this transaction.If you want to get most out of performance, it is best to make use of a customized
TxnExecutorinstead of relying on the default TxnExecutor that will always provide the most expensive transaction available.- Parameters:
callable- TheTxnCallableto execute.- Returns:
- the result of the execution
- Throws:
NullPointerException- if callable is null.Exception- is the callable throws an Exception
-
atomic
public static <E> E atomic(TxnCallable<E> either, TxnCallable<E> orelse)
Executes the either block, or in case of a retry, the orelse block is executed. If in the execution of the callable a checked exception is thrown, the exception is wrapped in a InvisibleCheckedException. The original exception can be retrieved by calling the getCause method.- Parameters:
either- the either blockorelse- the orelse block.- Returns:
- the result of the execution.
- Throws:
NullPointerException- if callable is null.InvisibleCheckedException- if a checked exception is thrown by the callable.
-
atomicChecked
public static <E> E atomicChecked(TxnCallable<E> either, TxnCallable<E> orelse) throws Exception
Executes the either block, or in case of a retry, the orelse block is executed.- Parameters:
either- the either blockorelse- the orelse block- Returns:
- the result of the execution.
- Throws:
NullPointerException- if callable is null.Exception- if the execute call fails.
-
atomic
public static int atomic(TxnIntCallable callable)
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor. If a Transaction already is active on the TxnThreadLocal, this transaction will lift on that transaction (so the propagation level is Requires) and will not commit this transaction.This method doesn't throw a checked exception, but if the callable does, it is wrapped inside an InvisibleCheckedException.
If you want to get most out of performance, it is best to make use of a customized
TxnExecutorinstead of relying on the default TxnExecutor that will always provide the most expensive transaction available.- Parameters:
callable- The callableTxnIntCallableto execute.- Returns:
- the result of the execution
- Throws:
NullPointerException- if callable is null.InvisibleCheckedException- if the callable throws a checked exception.
-
atomicChecked
public static int atomicChecked(TxnIntCallable callable) throws Exception
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor. If a Transaction already is active on the TxnThreadLocal, this transaction will lift on that transaction (so the propagation level is Requires) and will not commit this transaction.If you want to get most out of performance, it is best to make use of a customized
TxnExecutorinstead of relying on the default TxnExecutor that will always provide the most expensive transaction available.- Parameters:
callable- TheTxnIntCallableto execute.- Returns:
- the result of the execution
- Throws:
NullPointerException- if callable is null.Exception- is the callable throws an Exception
-
atomic
public static int atomic(TxnIntCallable either, TxnIntCallable orelse)
Executes the either block, or in case of a retry, the orelse block is executed. If in the execution of the callable a checked exception is thrown, the exception is wrapped in a InvisibleCheckedException. The original exception can be retrieved by calling the getCause method.- Parameters:
either- the either blockorelse- the orelse block.- Returns:
- the result of the execution.
- Throws:
NullPointerException- if callable is null.InvisibleCheckedException- if a checked exception is thrown by the callable.
-
atomicChecked
public static int atomicChecked(TxnIntCallable either, TxnIntCallable orelse) throws Exception
Executes the either block, or in case of a retry, the orelse block is executed.- Parameters:
either- the either blockorelse- the orelse block- Returns:
- the result of the execution.
- Throws:
NullPointerException- if callable is null.Exception- if the execute call fails.
-
atomic
public static long atomic(TxnLongCallable callable)
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor. If a Transaction already is active on the TxnThreadLocal, this transaction will lift on that transaction (so the propagation level is Requires) and will not commit this transaction.This method doesn't throw a checked exception, but if the callable does, it is wrapped inside an InvisibleCheckedException.
If you want to get most out of performance, it is best to make use of a customized
TxnExecutorinstead of relying on the default TxnExecutor that will always provide the most expensive transaction available.- Parameters:
callable- The callableTxnLongCallableto execute.- Returns:
- the result of the execution
- Throws:
NullPointerException- if callable is null.InvisibleCheckedException- if the callable throws a checked exception.
-
atomicChecked
public static long atomicChecked(TxnLongCallable callable) throws Exception
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor. If a Transaction already is active on the TxnThreadLocal, this transaction will lift on that transaction (so the propagation level is Requires) and will not commit this transaction.If you want to get most out of performance, it is best to make use of a customized
TxnExecutorinstead of relying on the default TxnExecutor that will always provide the most expensive transaction available.- Parameters:
callable- TheTxnLongCallableto execute.- Returns:
- the result of the execution
- Throws:
NullPointerException- if callable is null.Exception- is the callable throws an Exception
-
atomic
public static long atomic(TxnLongCallable either, TxnLongCallable orelse)
Executes the either block, or in case of a retry, the orelse block is executed. If in the execution of the callable a checked exception is thrown, the exception is wrapped in a InvisibleCheckedException. The original exception can be retrieved by calling the getCause method.- Parameters:
either- the either blockorelse- the orelse block.- Returns:
- the result of the execution.
- Throws:
NullPointerException- if callable is null.InvisibleCheckedException- if a checked exception is thrown by the callable.
-
atomicChecked
public static long atomicChecked(TxnLongCallable either, TxnLongCallable orelse) throws Exception
Executes the either block, or in case of a retry, the orelse block is executed.- Parameters:
either- the either blockorelse- the orelse block- Returns:
- the result of the execution.
- Throws:
NullPointerException- if callable is null.Exception- if the execute call fails.
-
atomic
public static double atomic(TxnDoubleCallable callable)
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor. If a Transaction already is active on the TxnThreadLocal, this transaction will lift on that transaction (so the propagation level is Requires) and will not commit this transaction.This method doesn't throw a checked exception, but if the callable does, it is wrapped inside an InvisibleCheckedException.
If you want to get most out of performance, it is best to make use of a customized
TxnExecutorinstead of relying on the default TxnExecutor that will always provide the most expensive transaction available.- Parameters:
callable- The callableTxnDoubleCallableto execute.- Returns:
- the result of the execution
- Throws:
NullPointerException- if callable is null.InvisibleCheckedException- if the callable throws a checked exception.
-
atomicChecked
public static double atomicChecked(TxnDoubleCallable callable) throws Exception
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor. If a Transaction already is active on the TxnThreadLocal, this transaction will lift on that transaction (so the propagation level is Requires) and will not commit this transaction.If you want to get most out of performance, it is best to make use of a customized
TxnExecutorinstead of relying on the default TxnExecutor that will always provide the most expensive transaction available.- Parameters:
callable- TheTxnDoubleCallableto execute.- Returns:
- the result of the execution
- Throws:
NullPointerException- if callable is null.Exception- is the callable throws an Exception
-
atomic
public static double atomic(TxnDoubleCallable either, TxnDoubleCallable orelse)
Executes the either block, or in case of a retry, the orelse block is executed. If in the execution of the callable a checked exception is thrown, the exception is wrapped in a InvisibleCheckedException. The original exception can be retrieved by calling the getCause method.- Parameters:
either- the either blockorelse- the orelse block.- Returns:
- the result of the execution.
- Throws:
NullPointerException- if callable is null.InvisibleCheckedException- if a checked exception is thrown by the callable.
-
atomicChecked
public static double atomicChecked(TxnDoubleCallable either, TxnDoubleCallable orelse) throws Exception
Executes the either block, or in case of a retry, the orelse block is executed.- Parameters:
either- the either blockorelse- the orelse block- Returns:
- the result of the execution.
- Throws:
NullPointerException- if callable is null.Exception- if the execute call fails.
-
atomic
public static boolean atomic(TxnBooleanCallable callable)
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor. If a Transaction already is active on the TxnThreadLocal, this transaction will lift on that transaction (so the propagation level is Requires) and will not commit this transaction.This method doesn't throw a checked exception, but if the callable does, it is wrapped inside an InvisibleCheckedException.
If you want to get most out of performance, it is best to make use of a customized
TxnExecutorinstead of relying on the default TxnExecutor that will always provide the most expensive transaction available.- Parameters:
callable- The callableTxnBooleanCallableto execute.- Returns:
- the result of the execution
- Throws:
NullPointerException- if callable is null.InvisibleCheckedException- if the callable throws a checked exception.
-
atomicChecked
public static boolean atomicChecked(TxnBooleanCallable callable) throws Exception
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor. If a Transaction already is active on the TxnThreadLocal, this transaction will lift on that transaction (so the propagation level is Requires) and will not commit this transaction.If you want to get most out of performance, it is best to make use of a customized
TxnExecutorinstead of relying on the default TxnExecutor that will always provide the most expensive transaction available.- Parameters:
callable- TheTxnBooleanCallableto execute.- Returns:
- the result of the execution
- Throws:
NullPointerException- if callable is null.Exception- is the callable throws an Exception
-
atomic
public static boolean atomic(TxnBooleanCallable either, TxnBooleanCallable orelse)
Executes the either block, or in case of a retry, the orelse block is executed. If in the execution of the callable a checked exception is thrown, the exception is wrapped in a InvisibleCheckedException. The original exception can be retrieved by calling the getCause method.- Parameters:
either- the either blockorelse- the orelse block.- Returns:
- the result of the execution.
- Throws:
NullPointerException- if callable is null.InvisibleCheckedException- if a checked exception is thrown by the callable.
-
atomicChecked
public static boolean atomicChecked(TxnBooleanCallable either, TxnBooleanCallable orelse) throws Exception
Executes the either block, or in case of a retry, the orelse block is executed.- Parameters:
either- the either blockorelse- the orelse block- Returns:
- the result of the execution.
- Throws:
NullPointerException- if callable is null.Exception- if the execute call fails.
-
atomic
public static void atomic(TxnVoidCallable callable)
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor. If a Transaction already is active on the TxnThreadLocal, this transaction will lift on that transaction (so the propagation level is Requires) and will not commit this transaction.This method doesn't throw a checked exception, but if the callable does, it is wrapped inside an InvisibleCheckedException.
If you want to get most out of performance, it is best to make use of a customized
TxnExecutorinstead of relying on the default TxnExecutor that will always provide the most expensive transaction available.- Parameters:
callable- The callableTxnVoidCallableto execute.- Throws:
NullPointerException- if callable is null.InvisibleCheckedException- if the callable throws a checked exception.
-
atomicChecked
public static void atomicChecked(TxnVoidCallable callable) throws Exception
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor. If a Transaction already is active on the TxnThreadLocal, this transaction will lift on that transaction (so the propagation level is Requires) and will not commit this transaction.If you want to get most out of performance, it is best to make use of a customized
TxnExecutorinstead of relying on the default TxnExecutor that will always provide the most expensive transaction available.- Parameters:
callable- TheTxnVoidCallableto execute.- Throws:
NullPointerException- if callable is null.Exception- is the callable throws an Exception
-
atomic
public static void atomic(TxnVoidCallable either, TxnVoidCallable orelse)
Executes the either block, or in case of a retry, the orelse block is executed. If in the execution of the callable a checked exception is thrown, the exception is wrapped in a InvisibleCheckedException. The original exception can be retrieved by calling the getCause method.- Parameters:
either- the either blockorelse- the orelse block.- Throws:
NullPointerException- if callable is null.InvisibleCheckedException- if a checked exception is thrown by the callable.
-
atomicChecked
public static void atomicChecked(TxnVoidCallable either, TxnVoidCallable orelse) throws Exception
Executes the either block, or in case of a retry, the orelse block is executed.- Parameters:
either- the either blockorelse- the orelse block- Throws:
NullPointerException- if callable is null.Exception- if the execute call fails.
-
newTxnInteger
public static TxnInteger newTxnInteger(int value)
Creates a committedTxnIntegerwith the provided value using theGlobalStmInstance.- Parameters:
value- the initial value of the TnxInteger- Returns:
- the created TnxInteger.
-
newTxnInteger
public static TxnInteger newTxnInteger()
Creates a committedTxnIntegerwith 0 as initial value using theGlobalStmInstance.- Returns:
- the created TxnInteger.
-
newTxnLong
public static TxnLong newTxnLong()
Creates a committedTxnLongwith 0 as initial value using theGlobalStmInstance.- Returns:
- the created TnxLong.
-
newTxnLong
public static TxnLong newTxnLong(long value)
Creates a committedTxnLongwith the provided value using theGlobalStmInstance.- Parameters:
value- the initial value of the TxnLong.- Returns:
- the created TnxLong.
-
newTxnDouble
public static TxnDouble newTxnDouble()
Creates a committedTxnDoublewith 0 as initial value using theGlobalStmInstance.- Returns:
- the created TxnDouble.
-
newTxnDouble
public static TxnDouble newTxnDouble(double value)
Creates a committedTxnDoublewith the provided value using theGlobalStmInstance.- Parameters:
value- the initial value.- Returns:
- the created TnxDouble.
-
newTxnBoolean
public static TxnBoolean newTxnBoolean()
Creates a committedTxnBooleanwith false as initial value using theGlobalStmInstance.- Returns:
- the created TxnBoolean.
-
newTxnBoolean
public static TxnBoolean newTxnBoolean(boolean value)
Creates a committedTxnBooleanwith the provided value using theGlobalStmInstance.- Parameters:
value- the initial value- Returns:
- the created TxnBoolean.
-
newTxnRef
public static <E> TxnRef<E> newTxnRef()
Creates a committedTxnRefwith null as initial value using theGlobalStmInstance.- Type Parameters:
E- the type of the TxnRef.- Returns:
- the created Ref.
-
newTxnRef
public static <E> TxnRef<E> newTxnRef(E value)
Creates a committedTxnRefwith the provided value using theGlobalStmInstance.- Type Parameters:
E- the type of the TxnRef.- Parameters:
value- the initial value of the TxnRef.- Returns:
- the created TxnRef.
-
retry
public static void retry()
Does a retry. This behavior is needed for blocking transactions; transaction that wait for a state change to happen on certain datastructures, e.g. an item to come available on a transactional blocking queue.Under the hood the retry throws an Retry that will be caught up the callstack (by the
TxnExecutorfor example). The Retry should not be caught by user code in almost all cases.
-
prepare
public static void prepare()
Prepares the Transaction in the TxnThreadLocal transaction.For more information see
Txn.prepare().- Throws:
TxnMandatoryException- if no active transaction is found.IllegalTransactionStateException- if the active transaction is not in the correct state for this operation.ControlFlowError
-
abort
public static void abort()
Aborts the Transaction in the TxnThreadLocal transaction.For more information see
Txn.abort().- Throws:
TxnMandatoryException- if no active transaction is found.IllegalTransactionStateException- if the active transaction is not in the correct state for this operation.ControlFlowError
-
commit
public static void commit()
Commits the Transaction in the TxnThreadLocal transaction.For more information see
Txn.commit().- Throws:
TxnMandatoryException- if no active transaction is found.IllegalTransactionStateException- if the active transaction is not in the correct state for this operation.ControlFlowError
-
scheduleCompensatingOrDeferredTask
public static void scheduleCompensatingOrDeferredTask(Runnable task)
Scheduled an deferred or compensating task on theTxnin the TxnThreadLocal. This task is executed after the transaction commits or aborts.- Parameters:
task- the deferred task to execute.- Throws:
NullPointerException- if task is null.TxnMandatoryException- if no transaction is set on theTxnThreadLocal.IllegalTxnStateException- if the transaction is not in the correct state to accept a compensating or deferred task.
-
scheduleDeferredTask
public static void scheduleDeferredTask(Runnable task)
Scheduled an deferred task on theTxnin theTxnThreadLocal. This task is executed after the transaction commits and one of the use cases is starting transactions.- Parameters:
task- the deferred task to execute.- Throws:
NullPointerException- if task is null.TxnMandatoryException- if no transaction is set on theTxnThreadLocal.IllegalTxnStateException- if the transaction is not in the correct state to accept a deferred task.
-
scheduleCompensatingTask
public static void scheduleCompensatingTask(Runnable task)
Scheduled a compensating task on theTxnin theTxnThreadLocal. This task is executed after the transaction aborts and one of the use cases is cleaning up non transaction resources like the file system.- Parameters:
task- the deferred task to execute.- Throws:
NullPointerException- if task is null.TxnMandatoryException- if no transaction is set on theTxnThreadLocal.IllegalTxnStateException- if the transaction is not in the correct state to accept a compensating task.
-
-