Package org.nuxeo.ecm.core.api
Class LockHelper
- java.lang.Object
-
- org.nuxeo.ecm.core.api.LockHelper
-
public class LockHelper extends Object
Utilities to work with locks- Since:
- 9.3
-
-
Field Summary
Fields Modifier and Type Field Description static StringDOCUMENT_LOCKstatic StringLOCKstatic intNB_TRYstatic intSLEEP_DURATION
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voiddoAtomically(String key, Runnable runnable)Runs aRunnableatomically, in a cluster-wide critical section.static <R> RdoAtomically(String key, Supplier<R> supplier)Runs aSupplieratomically, in a cluster-wide critical section.protected static booleantryLock(String key, KeyValueStore kvStore)protected static voidunlock(String key, KeyValueStore kvStore)
-
-
-
Field Detail
-
DOCUMENT_LOCK
public static final String DOCUMENT_LOCK
- See Also:
- Constant Field Values
-
LOCK
public static final String LOCK
- See Also:
- Constant Field Values
-
NB_TRY
public static final int NB_TRY
- See Also:
- Constant Field Values
-
SLEEP_DURATION
public static final int SLEEP_DURATION
- See Also:
- Constant Field Values
-
-
Method Detail
-
doAtomically
public static void doAtomically(String key, Runnable runnable) throws ConcurrentUpdateException
Runs aRunnableatomically, in a cluster-wide critical section.- Parameters:
key- the key used to determine atomicityrunnable- the runnable- Throws:
ConcurrentUpdateException
-
doAtomically
public static <R> R doAtomically(String key, Supplier<R> supplier) throws ConcurrentUpdateException
Runs aSupplieratomically, in a cluster-wide critical section.- Parameters:
key- the key used to determine atomicitysupplier- the supplier- Returns:
- the result of the function
- Throws:
ConcurrentUpdateException
-
tryLock
protected static boolean tryLock(String key, KeyValueStore kvStore) throws InterruptedException
- Throws:
InterruptedException
-
unlock
protected static void unlock(String key, KeyValueStore kvStore)
-
-