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 booleanremoveWithInstanceIdentifier(ConcurrentMap<String,String> map, String lockName)Removes the entry with keylockNamefrom map if the value of the entry is equal to this node's identifierstatic voidrepeatPutIfAbsent(org.infinispan.client.hotrod.RemoteCache<String,String> locksCache, String lockName, Duration timeout, int repeatInterval)Repeatedly attempts to put an entry with the keylockNameto 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 keylockNameto 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 withintimeoutMillisecondsit gives up and returns false. There is a pause after each unsuccessful attempt equal torepeatIntervalmilliseconds- 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 keylockNamewas NOT put into themapwithin time boundariesIllegalStateException- when alockvalue 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 keylockNamefrom 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
-
-