Class PersistentSessionsChangelogBasedTransaction<K,V extends SessionEntity>
- All Implemented Interfaces:
SessionsChangelogBasedTransaction<K,,V> NonBlockingTransaction
- Direct Known Subclasses:
ClientSessionPersistentChangelogBasedTransaction,UserSessionPersistentChangelogBasedTransaction
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final KeycloakSessionprotected final Map<K,SessionUpdatesList<V>> protected final Map<K,SessionUpdatesList<V>> -
Constructor Summary
ConstructorsConstructorDescriptionPersistentSessionsChangelogBasedTransaction(KeycloakSession session, String cacheName, CacheHolder<K, V> cacheHolder, CacheHolder<K, V> offlineCacheHolder) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTask(K key, SessionUpdateTask<V> originalTask) voidaddTask(K key, SessionUpdateTask<V> task, V entity, UserSessionModel.SessionPersistenceState persistenceState) voidasyncCommit(org.infinispan.commons.util.concurrent.AggregateCompletionStage<Void> stage, Consumer<DatabaseUpdate> databaseUpdates) Asynchronously commits the transaction.voidasyncRollback(org.infinispan.commons.util.concurrent.AggregateCompletionStage<Void> stage) Asynchronously rollbacks the transaction.org.infinispan.Cache<K,SessionEntityWrapper<V>> getCache(boolean offline) protected SessionFunction<V>getLifespanMsLoader(boolean offline) protected SessionFunction<V>getMaxIdleMsLoader(boolean offline) protected Map<K,SessionUpdatesList<V>> getUpdates(boolean offline) importSession(RealmModel realmModel, K key, SessionEntityWrapper<V> session, boolean offline, long lifespan, long maxIdle) Imports a session from an external source into theCache.voidimportSessionsConcurrently(RealmModel realmModel, Map<K, SessionEntityWrapper<V>> sessions, boolean offline) Imports multiple sessions from an external source into theCache.booleanLocking any entities that are about to be updated.protected abstract booleanlockDatabaseEntity(RealmModel realm, K key, boolean offline, SessionUpdateTask.CacheOperation operation) Lock the entity in the database.voidreloadEntityInCurrentTransaction(RealmModel realm, K key, SessionEntityWrapper<V> entity) Deprecated, for removal: This API element is subject to removal in a future version.voidrestartEntity(K key, SessionUpdateTask<V> restartTask) booleanThis transaction connects to entities in the database.
-
Field Details
-
kcSession
-
updates
-
offlineUpdates
-
-
Constructor Details
-
PersistentSessionsChangelogBasedTransaction
public PersistentSessionsChangelogBasedTransaction(KeycloakSession session, String cacheName, CacheHolder<K, V> cacheHolder, CacheHolder<K, V> offlineCacheHolder)
-
-
Method Details
-
getCache
-
getLifespanMsLoader
-
getMaxIdleMsLoader
-
getUpdates
-
generateKey
-
get
-
supportsLockingDatabaseEntities
public boolean supportsLockingDatabaseEntities()Description copied from interface:NonBlockingTransactionThis transaction connects to entities in the database.- Specified by:
supportsLockingDatabaseEntitiesin interfaceNonBlockingTransaction- Returns:
- When this returns true, this has entities in the database
-
lockDatabaseEntities
public boolean lockDatabaseEntities()Description copied from interface:NonBlockingTransactionLocking any entities that are about to be updated.- Specified by:
lockDatabaseEntitiesin interfaceNonBlockingTransaction- Returns:
- When this returns true, there is either no entity to be locked, or all entities are now locked and it is unlikely that the transaction will roll back.
-
lockDatabaseEntity
protected abstract boolean lockDatabaseEntity(RealmModel realm, K key, boolean offline, SessionUpdateTask.CacheOperation operation) Lock the entity in the database. -
asyncCommit
public void asyncCommit(org.infinispan.commons.util.concurrent.AggregateCompletionStage<Void> stage, Consumer<DatabaseUpdate> databaseUpdates) Description copied from interface:NonBlockingTransactionAsynchronously commits the transaction.The implementation should not block the thread and add any (or none)
CompletionStageinto thestage.Any blocking operation should be consumed by the
databaseUpdates. It will be executed at a later instant.- Specified by:
asyncCommitin interfaceNonBlockingTransaction- Parameters:
stage- TheAggregateCompletionStageto collect theCompletionStage.databaseUpdates- TheConsumerto use for blocking/database updates.
-
asyncRollback
public void asyncRollback(org.infinispan.commons.util.concurrent.AggregateCompletionStage<Void> stage) Description copied from interface:NonBlockingTransactionAsynchronously rollbacks the transaction.The implementation should not block the thread and add any (or none)
CompletionStageinto thestage.- Specified by:
asyncRollbackin interfaceNonBlockingTransaction- Parameters:
stage- TheAggregateCompletionStageto collect theCompletionStage.
-
addTask
- Specified by:
addTaskin interfaceSessionsChangelogBasedTransaction<K,V extends SessionEntity>
-
restartEntity
- Specified by:
restartEntityin interfaceSessionsChangelogBasedTransaction<K,V extends SessionEntity>
-
addTask
public void addTask(K key, SessionUpdateTask<V> task, V entity, UserSessionModel.SessionPersistenceState persistenceState) -
reloadEntityInCurrentTransaction
@Deprecated(forRemoval=true, since="26.4") public void reloadEntityInCurrentTransaction(RealmModel realm, K key, SessionEntityWrapper<V> entity) Deprecated, for removal: This API element is subject to removal in a future version. -
importSession
public SessionEntityWrapper<V> importSession(RealmModel realmModel, K key, SessionEntityWrapper<V> session, boolean offline, long lifespan, long maxIdle) Imports a session from an external source into theCache.If a session already exists in the cache, this method does not insert the
session. The invoker should use the session returned by this method invocation. When the session is successfully imported, this method returns null and thesessioncan be used by the transaction.This transaction will keep track of further changes in the session.
- Parameters:
realmModel- TheRealmModelwhere the session belong to.key- The cache's key.session- The session to import.lifespan- How long the session stays cached until it is expired and removed.maxIdle- How long the session can be idle (without reading or writing) before being removed.offline-trueif it is an offline session.- Returns:
- The existing cached session. If it returns
null, it means thesessionused in the parameters was cached.
-
importSessionsConcurrently
public void importSessionsConcurrently(RealmModel realmModel, Map<K, SessionEntityWrapper<V>> sessions, boolean offline) Imports multiple sessions from an external source into theCache.If one or more sessions already exist in the
Cache, or is expired, it will not be imported.This transaction will keep track of further changes in the sessions.
- Parameters:
realmModel- TheRealmModelwhere the sessions belong to.sessions- TheMapwith the cache's key/session mapping to be imported.offline-trueif it is an offline session.
-