Package org.openspaces.core.map
Class LockManager
java.lang.Object
org.openspaces.core.map.LockManager
The lock manager is built on top of
IMap and supports the ability to lock and unlock
certain keys within the map.- Author:
- kimchy
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ObjectA empty lock value written to indicate a lock when there is no value to lock on (i.e. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisEmptyLockValue(Object value) booleanReturnstrueif the given key is locked.Locks the given key for any updates.voidputAndUnlock(Object key, Object value) Unlocks the given key and puts the given value in a single operation.voidUnlocks the given lock on the key
-
Field Details
-
EMPTY_LOCK_VALUE
A empty lock value written to indicate a lock when there is no value to lock on (i.e. calling lock on a key where there is no value in the cache).
-
-
Constructor Details
-
LockManager
Creates a new Lock Manager based on theIMap.
-
-
Method Details
-
isEmptyLockValue
-
lock
Locks the given key for any updates. Retruns aLockHandlethat can be used to perform specific updates under the same lock (by using the transaction object stored within it).Might create an empty value if there is no value in order to lock on. The empty value can be checked using
isEmptyLockValue(Object).- Parameters:
key- The key to locklockTimeToLive- The lock time to live (in milliseconds)timeoutWaitingForLock- The time to wait for an already locked lock- Returns:
- LockHandle that can be used to perfrom operations under the given lock
-
putAndUnlock
Unlocks the given key and puts the given value in a single operation.- Parameters:
key- The key to unlock and put the value invalue- The value to put after unlocking the key
-
islocked
Returnstrueif the given key is locked. Otherwise returnsfalse.- Parameters:
key- The key to check if it locked or not.- Returns:
trueif the given key is locked or not.
-
unlock
Unlocks the given lock on the key- Parameters:
key- The key to unlock
-