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 SummaryNested Classes Modifier and Type Interface Description static classSessionLoader.LoaderContextObject, which contains some context data to be used by SessionLoader implementation.static classSessionLoader.WorkerContextObject, which is computed before each worker iteration and contains some data to be used by the corresponding worker iteration.static classSessionLoader.WorkerResultResult of single worker iteration
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description voidafterAllSessionsLoaded(BaseCacheInitializer initializer)Callback triggered on cluster coordinator once it recognize that all sessions were successfully loadedLOADER_CONTEXTcomputeLoaderContext(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.WORKER_CONTEXTcomputeWorkerContext(LOADER_CONTEXT loaderCtx, int segment, int workerId, WORKER_RESULT previousResult)Compute the worker context for current iterationWORKER_RESULTcreateFailedWorkerResult(LOADER_CONTEXT loaderContext, WORKER_CONTEXT workerContext)Called when it's not possible to compute current iteration and load session for some reason (EG.voidinit(KeycloakSession session)Will be triggered just once on cluster coordinator node to perform some generic initialization tasks (Eg.booleanisFinished(BaseCacheInitializer initializer)This will be called on nodes to check if loading is finished.WORKER_RESULTloadSessions(KeycloakSession session, LOADER_CONTEXT loaderContext, WORKER_CONTEXT workerContext)Will be called on all cluster nodes to load the specified page.
 
- 
- 
- 
Method Detail- 
initvoid init(KeycloakSession session) 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-
 
 - 
computeLoaderContextLOADER_CONTEXT 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. 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:
 
 - 
computeWorkerContextWORKER_CONTEXT computeWorkerContext(LOADER_CONTEXT loaderCtx, int segment, int workerId, WORKER_RESULT previousResult) Compute the worker context for current iteration- Parameters:
- loaderCtx- global loader context
- segment- the current segment (page) to compute
- workerId- 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:
 
 - 
loadSessionsWORKER_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 before
- workerContext- for current iteration
- Returns:
 
 - 
createFailedWorkerResultWORKER_RESULT createFailedWorkerResult(LOADER_CONTEXT loaderContext, WORKER_CONTEXT workerContext) 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:
 
 - 
isFinishedboolean isFinished(BaseCacheInitializer initializer) 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:
 
 - 
afterAllSessionsLoadedvoid afterAllSessionsLoaded(BaseCacheInitializer initializer) Callback triggered on cluster coordinator once it recognize that all sessions were successfully loaded- Parameters:
- initializer-
 
 
- 
 
-