Class InfinispanChangelogBasedTransaction<K,V extends SessionEntity>
java.lang.Object
org.keycloak.models.AbstractKeycloakTransaction
org.keycloak.models.sessions.infinispan.changes.InfinispanChangelogBasedTransaction<K,V>
- All Implemented Interfaces:
KeycloakTransaction
,SessionsChangelogBasedTransaction<K,
V>
public class InfinispanChangelogBasedTransaction<K,V extends SessionEntity>
extends AbstractKeycloakTransaction
implements SessionsChangelogBasedTransaction<K,V>
- Author:
- Marek Posolda
-
Nested Class Summary
Nested classes/interfaces inherited from class org.keycloak.models.AbstractKeycloakTransaction
AbstractKeycloakTransaction.TransactionState
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.infinispan.Cache<K,
SessionEntityWrapper<V>> protected final KeycloakSession
protected final SessionFunction<V>
static final org.jboss.logging.Logger
protected final SessionFunction<V>
protected final Map<K,
SessionUpdatesList<V>> Fields inherited from class org.keycloak.models.AbstractKeycloakTransaction
state
-
Constructor Summary
ConstructorsConstructorDescriptionInfinispanChangelogBasedTransaction
(KeycloakSession kcSession, org.infinispan.Cache<K, SessionEntityWrapper<V>> cache, SessionFunction<V> lifespanMsLoader, SessionFunction<V> maxIdleTimeMsLoader, SerializeExecutionsByKey<K> serializer) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addTask
(K key, SessionUpdateTask<V> task) void
addTask
(K key, SessionUpdateTask<V> task, V entity, UserSessionModel.SessionPersistenceState persistenceState) protected void
org.infinispan.Cache<K,
SessionEntityWrapper<V>> getCache()
importSession
(RealmModel realmModel, K key, SessionEntityWrapper<V> session, long lifespan, long maxIdle) Imports a session from an external source into theCache
.void
importSessionsConcurrently
(RealmModel realmModel, Map<K, SessionEntityWrapper<V>> sessions, SessionFunction<V> lifespanFunction, SessionFunction<V> maxIdleFunction) Imports multiple sessions from an external source into theCache
.void
reloadEntityInCurrentTransaction
(RealmModel realm, K key, SessionEntityWrapper<V> entity) protected void
Methods inherited from class org.keycloak.models.AbstractKeycloakTransaction
begin, beginImpl, commit, getRollbackOnly, getState, isActive, rollback, setRollbackOnly
-
Field Details
-
logger
public static final org.jboss.logging.Logger logger -
kcSession
-
cache
-
updates
-
lifespanMsLoader
-
maxIdleTimeMsLoader
-
-
Constructor Details
-
InfinispanChangelogBasedTransaction
public InfinispanChangelogBasedTransaction(KeycloakSession kcSession, org.infinispan.Cache<K, SessionEntityWrapper<V>> cache, SessionFunction<V> lifespanMsLoader, SessionFunction<V> maxIdleTimeMsLoader, SerializeExecutionsByKey<K> serializer)
-
-
Method Details
-
addTask
- Specified by:
addTask
in interfaceSessionsChangelogBasedTransaction<K,
V extends SessionEntity>
-
addTask
public void addTask(K key, SessionUpdateTask<V> task, V entity, UserSessionModel.SessionPersistenceState persistenceState) -
reloadEntityInCurrentTransaction
public void reloadEntityInCurrentTransaction(RealmModel realm, K key, SessionEntityWrapper<V> entity) -
get
-
commitImpl
protected void commitImpl()- Specified by:
commitImpl
in classAbstractKeycloakTransaction
-
rollbackImpl
protected void rollbackImpl()- Specified by:
rollbackImpl
in classAbstractKeycloakTransaction
-
getCache
- Returns:
- The
Cache
backing up this transaction.
-
importSession
public V importSession(RealmModel realmModel, K key, SessionEntityWrapper<V> session, 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 thesession
can be used by the transaction.This transaction will keep track of further changes in the session.
- Parameters:
realmModel
- TheRealmModel
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.- Returns:
- The existing cached session. If it returns
null
, it means thesession
used in the parameters was cached.
-
importSessionsConcurrently
public void importSessionsConcurrently(RealmModel realmModel, Map<K, SessionEntityWrapper<V>> sessions, SessionFunction<V> lifespanFunction, SessionFunction<V> maxIdleFunction) Imports multiple sessions from an external source into theCache
.If the
lifespanFunction
ormaxIdleFunction
returnsSessionTimeouts.ENTRY_EXPIRED_FLAG
, the session is considered expired and not stored in the cache.Also, if one or more sessions already exist in the
Cache
, it will not be imported.This transaction will keep track of further changes in the sessions.
- Parameters:
realmModel
- TheRealmModel
where the sessions belong to.sessions
- TheMap
with the cache's key/session mapping to be imported.lifespanFunction
- TheFunction
to compute the lifespan of the session. It defines how long the session should be stored in the cache until it is removed.maxIdleFunction
- TheFunction
to compute the max-idle of the session. It defines how long the session will be idle before it is removed.
-