Package org.keycloak.models.dblock
Class DBLockGlobalLockProvider
- java.lang.Object
- 
- org.keycloak.models.dblock.DBLockGlobalLockProvider
 
- 
- All Implemented Interfaces:
- GlobalLockProvider,- Provider
 
 public class DBLockGlobalLockProvider extends Object implements GlobalLockProvider 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.keycloak.models.locking.GlobalLockProviderGlobalLockProvider.Constants
 
- 
 - 
Constructor SummaryConstructors Constructor Description DBLockGlobalLockProvider(KeycloakSession session, DBLockProvider dbLockProvider)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidforceReleaseAllLocks()Releases all locks acquired by this GlobalLockProvider.<V> VwithLock(String lockName, Duration timeToWaitForLock, KeycloakSessionTaskWithResult<V> task)Acquires a new non-reentrant global lock that is visible to all Keycloak nodes.- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.keycloak.models.locking.GlobalLockProviderwithLock
 
- 
 
- 
- 
- 
Field Detail- 
DATABASEpublic static final String DATABASE - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
DBLockGlobalLockProviderpublic DBLockGlobalLockProvider(KeycloakSession session, DBLockProvider dbLockProvider) 
 
- 
 - 
Method Detail- 
withLockpublic <V> V withLock(String lockName, Duration timeToWaitForLock, KeycloakSessionTaskWithResult<V> task) Acquires a new non-reentrant global lock that is visible to all Keycloak nodes. If the lock was successfully acquired the method runs thetaskand return result to the caller. SeeGlobalLockProvider.withLock(String, Duration, KeycloakSessionTaskWithResult)for more details. This implementation does NOT meet all requirements from the JavaDoc ofGlobalLockProvider.withLock(String, Duration, KeycloakSessionTaskWithResult)becauseDBLockProviderdoes not provide a way to lock and unlock in separate transactions. Also, the database schema update currently requires to be running in the same thread that initiated the update therefore thetaskis also running in the caller thread/transaction.- Specified by:
- withLockin interface- GlobalLockProvider
- Type Parameters:
- V- Type of object returned by the- task
- Parameters:
- lockName- Identifier used for acquiring lock. Can be any non-null string.
- timeToWaitForLock- Duration this method waits until it gives up acquiring the lock. If- null, each implementation should provide some default duration, for example, using a configuration option.
- task- The task that will be executed under the acquired lock
- Returns:
- Value returned by the task
 
 - 
forceReleaseAllLockspublic void forceReleaseAllLocks() Description copied from interface:GlobalLockProviderReleases all locks acquired by this GlobalLockProvider. This method unlocks all existing locks acquired by this provider regardless of the thread or Keycloak instance that originally acquired them.- Specified by:
- forceReleaseAllLocksin interface- GlobalLockProvider
 
 
- 
 
-