Class HotRodLocksUtils
- java.lang.Object
-
- org.keycloak.models.map.storage.hotRod.locking.HotRodLocksUtils
-
public class HotRodLocksUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description HotRodLocksUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
removeWithInstanceIdentifier(ConcurrentMap<String,String> map, String lockName)
Removes the entry with keylockName
from map if the value of the entry is equal to this node's identifierstatic void
repeatPutIfAbsent(org.infinispan.client.hotrod.RemoteCache<String,String> locksCache, String lockName, Duration timeout, int repeatInterval)
Repeatedly attempts to put an entry with the keylockName
to thelocksCache
.
-
-
-
Field Detail
-
SEPARATOR
public static final String SEPARATOR
- See Also:
- Constant Field Values
-
-
Method Detail
-
repeatPutIfAbsent
public static void repeatPutIfAbsent(org.infinispan.client.hotrod.RemoteCache<String,String> locksCache, String lockName, Duration timeout, int repeatInterval) throws LockAcquiringTimeoutException
Repeatedly attempts to put an entry with the keylockName
to thelocksCache
. Succeeds only if there is no entry with the same key already. Execution of this method is time bounded, if this method does not succeed withintimeoutMilliseconds
it gives up and returns false. There is a pause after each unsuccessful attempt equal torepeatInterval
milliseconds- Parameters:
locksCache
- Cache that will be used for putting the valuelockName
- Name of the entrytimeout
- duration to wait until the lock is acquiredrepeatInterval
- Number of milliseconds to wait after each unsuccessful attempt- Throws:
LockAcquiringTimeoutException
- the keylockName
was NOT put into themap
within time boundariesIllegalStateException
- when alock
value found in the storage has wrong format. It is expected the lock value has the following format'timeAcquired;keycloakInstanceIdentifier'
-
removeWithInstanceIdentifier
public static boolean removeWithInstanceIdentifier(ConcurrentMap<String,String> map, String lockName)
Removes the entry with keylockName
from map if the value of the entry is equal to this node's identifier- Parameters:
map
- Map that will be used for removinglockName
- Name of the entry- Returns:
- true if the entry was removed, false otherwise
-
-