Class PersistentSessionsChangelogBasedTransaction<K,V extends SessionEntity>

java.lang.Object
org.keycloak.models.sessions.infinispan.changes.PersistentSessionsChangelogBasedTransaction<K,V>
All Implemented Interfaces:
SessionsChangelogBasedTransaction<K,V>, NonBlockingTransaction
Direct Known Subclasses:
ClientSessionPersistentChangelogBasedTransaction, UserSessionPersistentChangelogBasedTransaction

public abstract class PersistentSessionsChangelogBasedTransaction<K,V extends SessionEntity> extends Object implements SessionsChangelogBasedTransaction<K,V>, NonBlockingTransaction
  • Field Details

  • Constructor Details

  • Method Details

    • getCache

      public org.infinispan.Cache<K,SessionEntityWrapper<V>> getCache(boolean offline)
    • getLifespanMsLoader

      protected SessionFunction<V> getLifespanMsLoader(boolean offline)
    • getMaxIdleMsLoader

      protected SessionFunction<V> getMaxIdleMsLoader(boolean offline)
    • getUpdates

      protected Map<K,SessionUpdatesList<V>> getUpdates(boolean offline)
    • get

      public SessionEntityWrapper<V> get(K key, boolean offline)
    • asyncCommit

      public void asyncCommit(org.infinispan.commons.util.concurrent.AggregateCompletionStage<Void> stage, Consumer<DatabaseUpdate> databaseUpdates)
      Description copied from interface: NonBlockingTransaction
      Asynchronously commits the transaction.

      The implementation should not block the thread and add any (or none) CompletionStage into the stage.

      Any blocking operation should be consumed by the databaseUpdates. It will be executed at a later instant.

      Specified by:
      asyncCommit in interface NonBlockingTransaction
      Parameters:
      stage - The AggregateCompletionStage to collect the CompletionStage.
      databaseUpdates - The Consumer to use for blocking/database updates.
    • asyncRollback

      public void asyncRollback(org.infinispan.commons.util.concurrent.AggregateCompletionStage<Void> stage)
      Description copied from interface: NonBlockingTransaction
      Asynchronously rollbacks the transaction.

      The implementation should not block the thread and add any (or none) CompletionStage into the stage.

      Specified by:
      asyncRollback in interface NonBlockingTransaction
      Parameters:
      stage - The AggregateCompletionStage to collect the CompletionStage.
    • addTask

      public void addTask(K key, SessionUpdateTask<V> originalTask)
      Specified by:
      addTask in interface SessionsChangelogBasedTransaction<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 the Cache.

      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 the session can be used by the transaction.

      This transaction will keep track of further changes in the session.

      Parameters:
      realmModel - The RealmModel where 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 - true if it is an offline session.
      Returns:
      The existing cached session. If it returns null, it means the session used 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 the Cache.

      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 - The RealmModel where the sessions belong to.
      sessions - The Map with the cache's key/session mapping to be imported.
      offline - true if it is an offline session.