Package org.keycloak.models.dblock
Class DBLockGlobalLockProvider
java.lang.Object
org.keycloak.models.dblock.DBLockGlobalLockProvider
- All Implemented Interfaces:
GlobalLockProvider,Provider
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.keycloak.models.locking.GlobalLockProvider
GlobalLockProvider.Constants -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDBLockGlobalLockProvider(KeycloakSession session, DBLockProvider dbLockProvider) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()void<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.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.keycloak.models.locking.GlobalLockProvider
withLock
-
Field Details
-
DATABASE
- See Also:
-
-
Constructor Details
-
DBLockGlobalLockProvider
-
-
Method Details
-
withLock
public <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 interfaceGlobalLockProvider
-
forceReleaseAllLocks
public void forceReleaseAllLocks()- Specified by:
forceReleaseAllLocksin interfaceGlobalLockProvider
-
close
public void close()
-