Interface SessionLoader<LOADER_CONTEXT extends SessionLoader.LoaderContext,WORKER_CONTEXT extends SessionLoader.WorkerContext,WORKER_RESULT extends SessionLoader.WorkerResult>
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
OfflinePersistentUserSessionLoader
,RemoteCacheSessionsLoader
public interface SessionLoader<LOADER_CONTEXT extends SessionLoader.LoaderContext,WORKER_CONTEXT extends SessionLoader.WorkerContext,WORKER_RESULT extends SessionLoader.WorkerResult>
extends Serializable
- Author:
- Marek Posolda
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Object, which contains some context data to be used by SessionLoader implementation.static class
Object, which is computed before each worker iteration and contains some data to be used by the corresponding worker iteration.static class
Result of single worker iteration -
Method Summary
Modifier and TypeMethodDescriptionvoid
afterAllSessionsLoaded
(BaseCacheInitializer initializer) Callback triggered on cluster coordinator once it recognize that all sessions were successfully loadedcomputeLoaderContext
(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.computeWorkerContext
(LOADER_CONTEXT loaderCtx, int segment, int workerId, WORKER_RESULT previousResult) Compute the worker context for current iterationcreateFailedWorkerResult
(LOADER_CONTEXT loaderContext, WORKER_CONTEXT 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.loadSessions
(KeycloakSession session, LOADER_CONTEXT loaderContext, WORKER_CONTEXT workerContext) Will be called on all cluster nodes to load the specified page.
-
Method Details
-
init
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!- Parameters:
session
-
-
computeLoaderContext
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- Parameters:
session
-- Returns:
-
computeWorkerContext
WORKER_CONTEXT computeWorkerContext(LOADER_CONTEXT loaderCtx, int segment, int workerId, WORKER_RESULT previousResult) Compute the worker context for current iteration- 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:
-
loadSessions
WORKER_RESULT loadSessions(KeycloakSession session, LOADER_CONTEXT loaderContext, WORKER_CONTEXT workerContext) Will be called on all cluster nodes to load the specified page.- Parameters:
session
-loaderContext
- global loaderContext object, which was already computed beforeworkerContext
- for current iteration- Returns:
-
createFailedWorkerResult
Called when it's not possible to compute current iteration and load session for some reason (EG. infinispan not yet fully initialized)- Parameters:
loaderContext
-workerContext
-- Returns:
-
isFinished
This will be called on nodes to check if loading is finished. It allows loader to notify that loading is finished for some reason.- Parameters:
initializer
-- Returns:
-
afterAllSessionsLoaded
Callback triggered on cluster coordinator once it recognize that all sessions were successfully loaded- Parameters:
initializer
-
-