Package org.nuxeo.runtime.cluster
Class ClusterServiceImpl.ClusterLockHelper
- java.lang.Object
-
- org.nuxeo.runtime.cluster.ClusterServiceImpl.ClusterLockHelper
-
- Enclosing class:
- ClusterServiceImpl
public static class ClusterServiceImpl.ClusterLockHelper extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected Duration
duration
static String
KV_STORE_NAME
protected KeyValueStore
kvStore
protected String
nodeId
protected Duration
pollDelay
-
Constructor Summary
Constructors Constructor Description ClusterLockHelper(String nodeId, Duration duration, Duration pollDelay)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
getLock(String key)
void
runAtomically(String key, Runnable runnable)
Runs aRunnable
atomically in a cluster-wide critical section, outside a transaction.protected void
runAtomicallyInternal(String key, Runnable runnable)
Runs aRunnable
atomically, in a cluster-wide critical section.protected void
runInSeparateTransaction(Runnable runnable)
Runs aRunnable
outside the current transaction (committing and finally restarting it if needed).protected String
tryLock(String key)
protected void
unLock(String key, String lockInfo)
-
-
-
Field Detail
-
KV_STORE_NAME
public static final String KV_STORE_NAME
- See Also:
- Constant Field Values
-
kvStore
protected final KeyValueStore kvStore
-
-
Constructor Detail
-
ClusterLockHelper
public ClusterLockHelper(String nodeId, Duration duration, Duration pollDelay)
-
-
Method Detail
-
runAtomically
public void runAtomically(String key, Runnable runnable)
Runs aRunnable
atomically in a cluster-wide critical section, outside a transaction.
-
runInSeparateTransaction
protected void runInSeparateTransaction(Runnable runnable)
Runs aRunnable
outside the current transaction (committing and finally restarting it if needed).- Implementation Requirements:
- this is different from
TransactionHelper.runWithoutTransaction(Runnable)
because that one, in some implementations, may keep the current transaction and start the runnable in a new thread. Here we don't want a new thread or a risk of deadlock, so we just commit the original transaction.
-
runAtomicallyInternal
protected void runAtomicallyInternal(String key, Runnable runnable)
Runs aRunnable
atomically, in a cluster-wide critical section.
-
-