Class OfflinePersistentUserSessionLoader
- java.lang.Object
-
- org.keycloak.models.sessions.infinispan.initializer.OfflinePersistentUserSessionLoader
-
- All Implemented Interfaces:
Serializable
,SessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
public class OfflinePersistentUserSessionLoader extends Object implements SessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>, Serializable
- Author:
- Marek Posolda
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.keycloak.models.sessions.infinispan.initializer.SessionLoader
SessionLoader.LoaderContext, SessionLoader.WorkerContext, SessionLoader.WorkerResult
-
-
Field Summary
Fields Modifier and Type Field Description static String
PERSISTENT_SESSIONS_LOADED
static String
PERSISTENT_SESSIONS_LOADED_IN_CURRENT_DC
-
Constructor Summary
Constructors Constructor Description OfflinePersistentUserSessionLoader(int sessionsPerSegment)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterAllSessionsLoaded(BaseCacheInitializer initializer)
Callback triggered on cluster coordinator once it recognize that all sessions were successfully loadedOfflinePersistentLoaderContext
computeLoaderContext(KeycloakSession session)
Will be triggered just once on cluster coordinator node to count the number of segments and other context data specific to whole computation.OfflinePersistentWorkerContext
computeWorkerContext(OfflinePersistentLoaderContext loaderCtx, int segment, int workerId, OfflinePersistentWorkerResult previousResult)
Compute the worker context for current iterationOfflinePersistentWorkerResult
createFailedWorkerResult(OfflinePersistentLoaderContext loaderContext, OfflinePersistentWorkerContext workerContext)
Called when it's not possible to compute current iteration and load session for some reason (EG.void
init(KeycloakSession session)
Will be triggered just once on cluster coordinator node to perform some generic initialization tasks (Eg.boolean
isFinished(BaseCacheInitializer initializer)
This will be called on nodes to check if loading is finished.OfflinePersistentWorkerResult
loadSessions(KeycloakSession session, OfflinePersistentLoaderContext loaderContext, OfflinePersistentWorkerContext ctx)
Will be called on all cluster nodes to load the specified page.String
toString()
-
-
-
Field Detail
-
PERSISTENT_SESSIONS_LOADED
public static final String PERSISTENT_SESSIONS_LOADED
- See Also:
- Constant Field Values
-
PERSISTENT_SESSIONS_LOADED_IN_CURRENT_DC
public static final String PERSISTENT_SESSIONS_LOADED_IN_CURRENT_DC
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init(KeycloakSession session)
Description copied from interface:SessionLoader
Will be triggered just once on cluster coordinator node to perform some generic initialization tasks (Eg. update DB before starting load). NOTE: This shouldn't be used for the initialization of loader instance itself!- Specified by:
init
in interfaceSessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
-
computeLoaderContext
public OfflinePersistentLoaderContext computeLoaderContext(KeycloakSession session)
Description copied from interface:SessionLoader
Will be triggered just once on cluster coordinator node to count the number of segments and other context data specific to whole computation. Each segment will be then later computed in one "worker" task This method could be expensive to call, so the "computed" loaderContext object is passed among workers/loaders and needs to be serializable- Specified by:
computeLoaderContext
in interfaceSessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
- Returns:
-
computeWorkerContext
public OfflinePersistentWorkerContext computeWorkerContext(OfflinePersistentLoaderContext loaderCtx, int segment, int workerId, OfflinePersistentWorkerResult previousResult)
Description copied from interface:SessionLoader
Compute the worker context for current iteration- Specified by:
computeWorkerContext
in interfaceSessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
- Parameters:
loaderCtx
- global loader contextsegment
- the current segment (page) to computeworkerId
- ID of worker for current worker iteration. Usually the number 0-8 (with single cluster node)previousResult
- last workerResult from previous computation. Can be empty list in case of the operation is triggered for the 1st time- Returns:
-
createFailedWorkerResult
public OfflinePersistentWorkerResult createFailedWorkerResult(OfflinePersistentLoaderContext loaderContext, OfflinePersistentWorkerContext workerContext)
Description copied from interface:SessionLoader
Called when it's not possible to compute current iteration and load session for some reason (EG. infinispan not yet fully initialized)- Specified by:
createFailedWorkerResult
in interfaceSessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
- Returns:
-
loadSessions
public OfflinePersistentWorkerResult loadSessions(KeycloakSession session, OfflinePersistentLoaderContext loaderContext, OfflinePersistentWorkerContext ctx)
Description copied from interface:SessionLoader
Will be called on all cluster nodes to load the specified page.- Specified by:
loadSessions
in interfaceSessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
loaderContext
- global loaderContext object, which was already computed beforectx
- for current iteration- Returns:
-
isFinished
public boolean isFinished(BaseCacheInitializer initializer)
Description copied from interface:SessionLoader
This will be called on nodes to check if loading is finished. It allows loader to notify that loading is finished for some reason.- Specified by:
isFinished
in interfaceSessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
- Returns:
-
afterAllSessionsLoaded
public void afterAllSessionsLoaded(BaseCacheInitializer initializer)
Description copied from interface:SessionLoader
Callback triggered on cluster coordinator once it recognize that all sessions were successfully loaded- Specified by:
afterAllSessionsLoaded
in interfaceSessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
-
-