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 String
DOCUMENT_LOCK
static String
LOCK
static int
NB_TRY
static int
SLEEP_DURATION
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
doAtomically(String key, Runnable runnable)
Runs aRunnable
atomically, in a cluster-wide critical section.static <R> R
doAtomically(String key, Supplier<R> supplier)
Runs aSupplier
atomically, in a cluster-wide critical section.protected static boolean
tryLock(String key, KeyValueStore kvStore)
protected static void
unlock(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 aRunnable
atomically, 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 aSupplier
atomically, 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)
-
-