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.SessionLoaderSessionLoader.LoaderContext, SessionLoader.WorkerContext, SessionLoader.WorkerResult
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static StringPERSISTENT_SESSIONS_LOADEDstatic StringPERSISTENT_SESSIONS_LOADED_IN_CURRENT_DC
 - 
Constructor SummaryConstructors Constructor Description OfflinePersistentUserSessionLoader(int sessionsPerSegment)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterAllSessionsLoaded(BaseCacheInitializer initializer)Callback triggered on cluster coordinator once it recognize that all sessions were successfully loadedOfflinePersistentLoaderContextcomputeLoaderContext(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.OfflinePersistentWorkerContextcomputeWorkerContext(OfflinePersistentLoaderContext loaderCtx, int segment, int workerId, OfflinePersistentWorkerResult previousResult)Compute the worker context for current iterationOfflinePersistentWorkerResultcreateFailedWorkerResult(OfflinePersistentLoaderContext loaderContext, OfflinePersistentWorkerContext 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.OfflinePersistentWorkerResultloadSessions(KeycloakSession session, OfflinePersistentLoaderContext loaderContext, OfflinePersistentWorkerContext ctx)Will be called on all cluster nodes to load the specified page.StringtoString()
 
- 
- 
- 
Field Detail- 
PERSISTENT_SESSIONS_LOADEDpublic static final String PERSISTENT_SESSIONS_LOADED - See Also:
- Constant Field Values
 
 - 
PERSISTENT_SESSIONS_LOADED_IN_CURRENT_DCpublic static final String PERSISTENT_SESSIONS_LOADED_IN_CURRENT_DC - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
initpublic void init(KeycloakSession session) Description copied from interface:SessionLoaderWill 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:
- initin interface- SessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
 
 - 
computeLoaderContextpublic OfflinePersistentLoaderContext computeLoaderContext(KeycloakSession session) Description copied from interface:SessionLoaderWill 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:
- computeLoaderContextin interface- SessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
- Returns:
 
 - 
computeWorkerContextpublic OfflinePersistentWorkerContext computeWorkerContext(OfflinePersistentLoaderContext loaderCtx, int segment, int workerId, OfflinePersistentWorkerResult previousResult) Description copied from interface:SessionLoaderCompute the worker context for current iteration- Specified by:
- computeWorkerContextin interface- SessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
- 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:
 
 - 
createFailedWorkerResultpublic OfflinePersistentWorkerResult createFailedWorkerResult(OfflinePersistentLoaderContext loaderContext, OfflinePersistentWorkerContext workerContext) Description copied from interface:SessionLoaderCalled when it's not possible to compute current iteration and load session for some reason (EG. infinispan not yet fully initialized)- Specified by:
- createFailedWorkerResultin interface- SessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
- Returns:
 
 - 
loadSessionspublic OfflinePersistentWorkerResult loadSessions(KeycloakSession session, OfflinePersistentLoaderContext loaderContext, OfflinePersistentWorkerContext ctx) Description copied from interface:SessionLoaderWill be called on all cluster nodes to load the specified page.- Specified by:
- loadSessionsin interface- SessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
- loaderContext- global loaderContext object, which was already computed before
- ctx- for current iteration
- Returns:
 
 - 
isFinishedpublic boolean isFinished(BaseCacheInitializer initializer) Description copied from interface:SessionLoaderThis 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:
- isFinishedin interface- SessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
- Returns:
 
 - 
afterAllSessionsLoadedpublic void afterAllSessionsLoaded(BaseCacheInitializer initializer) Description copied from interface:SessionLoaderCallback triggered on cluster coordinator once it recognize that all sessions were successfully loaded- Specified by:
- afterAllSessionsLoadedin interface- SessionLoader<OfflinePersistentLoaderContext,OfflinePersistentWorkerContext,OfflinePersistentWorkerResult>
 
 
- 
 
-