public class OfflinePersistentUserSessionLoader extends Object implements SessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>, Serializable
SessionLoader.LoaderContext, SessionLoader.WorkerContext, SessionLoader.WorkerResult
Modifier and Type | Field and Description |
---|---|
static String |
PERSISTENT_SESSIONS_LOADED |
static String |
PERSISTENT_SESSIONS_LOADED_IN_CURRENT_DC |
Constructor and Description |
---|
OfflinePersistentUserSessionLoader(int sessionsPerSegment) |
Modifier and Type | Method and Description |
---|---|
void |
afterAllSessionsLoaded(BaseCacheInitializer initializer)
Callback triggered on cluster coordinator once it recognize that all sessions were successfully loaded
|
OfflinePersistentLoaderContext |
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 iteration
|
OfflinePersistentWorkerResult |
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() |
public static final String PERSISTENT_SESSIONS_LOADED
public static final String PERSISTENT_SESSIONS_LOADED_IN_CURRENT_DC
public OfflinePersistentUserSessionLoader(int sessionsPerSegment)
public void init(KeycloakSession session)
SessionLoader
init
in interface SessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
public OfflinePersistentLoaderContext computeLoaderContext(KeycloakSession session)
SessionLoader
computeLoaderContext
in interface SessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
public OfflinePersistentWorkerContext computeWorkerContext(OfflinePersistentLoaderContext loaderCtx, int segment, int workerId, OfflinePersistentWorkerResult previousResult)
SessionLoader
computeWorkerContext
in interface SessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
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 timepublic OfflinePersistentWorkerResult createFailedWorkerResult(OfflinePersistentLoaderContext loaderContext, OfflinePersistentWorkerContext workerContext)
SessionLoader
createFailedWorkerResult
in interface SessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
public OfflinePersistentWorkerResult loadSessions(KeycloakSession session, OfflinePersistentLoaderContext loaderContext, OfflinePersistentWorkerContext ctx)
SessionLoader
loadSessions
in interface SessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
loaderContext
- global loaderContext object, which was already computed beforectx
- for current iterationpublic boolean isFinished(BaseCacheInitializer initializer)
SessionLoader
isFinished
in interface SessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
public void afterAllSessionsLoaded(BaseCacheInitializer initializer)
SessionLoader
afterAllSessionsLoaded
in interface SessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
Copyright © 2020 JBoss by Red Hat. All rights reserved.