Class HotRodLocksUtils
java.lang.Object
org.keycloak.models.map.storage.hotRod.locking.HotRodLocksUtils
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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, boolean isReentrant) Repeatedly attempts to put an entry with the keylockName
to thelocksCache
.
-
Field Details
-
SEPARATOR
- See Also:
-
-
Constructor Details
-
HotRodLocksUtils
public HotRodLocksUtils()
-
-
Method Details
-
repeatPutIfAbsent
public static void repeatPutIfAbsent(org.infinispan.client.hotrod.RemoteCache<String, String> locksCache, String lockName, Duration timeout, int repeatInterval, boolean isReentrant) throws LockAcquiringTimeoutExceptionRepeatedly attempts to put an entry with the keylockName
to thelocksCache
. Succeeds only if there is no entry with the same key already. The value of created entry is equal to instance identifier. It is possible to make the method succeed even if the value already exists with the same instance identifier. This behaviour is enabled usingisReentrant
switch. 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 attemptisReentrant
- if this is set to true, the method succeeds also when the value for given key is equal to the instance identifier- 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
-