Class RemoteCacheSessionsLoader
java.lang.Object
org.keycloak.models.sessions.infinispan.remotestore.RemoteCacheSessionsLoader
- All Implemented Interfaces:
Serializable
,SessionLoader<RemoteCacheSessionsLoaderContext,
SessionLoader.WorkerContext, SessionLoader.WorkerResult>
public class RemoteCacheSessionsLoader
extends Object
implements SessionLoader<RemoteCacheSessionsLoaderContext,SessionLoader.WorkerContext,SessionLoader.WorkerResult>, Serializable
- Author:
- Marek Posolda
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.keycloak.models.sessions.infinispan.initializer.SessionLoader
SessionLoader.LoaderContext, SessionLoader.WorkerContext, SessionLoader.WorkerResult
-
Constructor Summary
-
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
(RemoteCacheSessionsLoaderContext loaderCtx, int segment, int workerId, SessionLoader.WorkerResult previousResult) Compute the worker context for current iterationcreateFailedWorkerResult
(RemoteCacheSessionsLoaderContext loaderContext, SessionLoader.WorkerContext workerContext) Called when it's not possible to compute current iteration and load session for some reason (EG.protected org.infinispan.Cache
getCache
(KeycloakSession session) protected org.infinispan.client.hotrod.RemoteCache
getRemoteCache
(KeycloakSession session) 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, RemoteCacheSessionsLoaderContext loaderContext, SessionLoader.WorkerContext ctx) Will be called on all cluster nodes to load the specified page.toString()
-
Constructor Details
-
RemoteCacheSessionsLoader
-
-
Method Details
-
init
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<RemoteCacheSessionsLoaderContext,
SessionLoader.WorkerContext, SessionLoader.WorkerResult>
-
computeLoaderContext
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<RemoteCacheSessionsLoaderContext,
SessionLoader.WorkerContext, SessionLoader.WorkerResult> - Returns:
-
computeWorkerContext
public SessionLoader.WorkerContext computeWorkerContext(RemoteCacheSessionsLoaderContext loaderCtx, int segment, int workerId, SessionLoader.WorkerResult previousResult) Description copied from interface:SessionLoader
Compute the worker context for current iteration- Specified by:
computeWorkerContext
in interfaceSessionLoader<RemoteCacheSessionsLoaderContext,
SessionLoader.WorkerContext, SessionLoader.WorkerResult> - 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 SessionLoader.WorkerResult createFailedWorkerResult(RemoteCacheSessionsLoaderContext loaderContext, SessionLoader.WorkerContext 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<RemoteCacheSessionsLoaderContext,
SessionLoader.WorkerContext, SessionLoader.WorkerResult> - Returns:
-
loadSessions
public SessionLoader.WorkerResult loadSessions(KeycloakSession session, RemoteCacheSessionsLoaderContext loaderContext, SessionLoader.WorkerContext ctx) Description copied from interface:SessionLoader
Will be called on all cluster nodes to load the specified page.- Specified by:
loadSessions
in interfaceSessionLoader<RemoteCacheSessionsLoaderContext,
SessionLoader.WorkerContext, SessionLoader.WorkerResult> loaderContext
- global loaderContext object, which was already computed beforectx
- for current iteration- Returns:
-
isFinished
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<RemoteCacheSessionsLoaderContext,
SessionLoader.WorkerContext, SessionLoader.WorkerResult> - Returns:
-
afterAllSessionsLoaded
Description copied from interface:SessionLoader
Callback triggered on cluster coordinator once it recognize that all sessions were successfully loaded- Specified by:
afterAllSessionsLoaded
in interfaceSessionLoader<RemoteCacheSessionsLoaderContext,
SessionLoader.WorkerContext, SessionLoader.WorkerResult>
-
getCache
-
getRemoteCache
-
toString
-