public class RemoteCacheSessionsLoader extends Object implements SessionLoader<RemoteCacheSessionsLoaderContext,SessionLoader.WorkerContext,SessionLoader.WorkerResult>, Serializable
SessionLoader.LoaderContext, SessionLoader.WorkerContext, SessionLoader.WorkerResult
Constructor and Description |
---|
RemoteCacheSessionsLoader(String cacheName,
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
|
RemoteCacheSessionsLoaderContext |
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.
|
SessionLoader.WorkerContext |
computeWorkerContext(RemoteCacheSessionsLoaderContext loaderCtx,
int segment,
int workerId,
SessionLoader.WorkerResult previousResult)
Compute the worker context for current iteration
|
SessionLoader.WorkerResult |
createFailedWorkerResult(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 int |
getIspnSegmentsCount(org.infinispan.client.hotrod.RemoteCache remoteCache) |
protected Set<Integer> |
getMyIspnSegments(int segment,
RemoteCacheSessionsLoaderContext ctx) |
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.
|
SessionLoader.WorkerResult |
loadSessions(KeycloakSession session,
RemoteCacheSessionsLoaderContext loaderContext,
SessionLoader.WorkerContext ctx)
Will be called on all cluster nodes to load the specified page.
|
String |
toString() |
public RemoteCacheSessionsLoader(String cacheName, int sessionsPerSegment)
public void init(KeycloakSession session)
SessionLoader
init
in interface SessionLoader<RemoteCacheSessionsLoaderContext,SessionLoader.WorkerContext,SessionLoader.WorkerResult>
public RemoteCacheSessionsLoaderContext computeLoaderContext(KeycloakSession session)
SessionLoader
computeLoaderContext
in interface SessionLoader<RemoteCacheSessionsLoaderContext,SessionLoader.WorkerContext,SessionLoader.WorkerResult>
protected int getIspnSegmentsCount(org.infinispan.client.hotrod.RemoteCache remoteCache)
public SessionLoader.WorkerContext computeWorkerContext(RemoteCacheSessionsLoaderContext loaderCtx, int segment, int workerId, SessionLoader.WorkerResult previousResult)
SessionLoader
computeWorkerContext
in interface SessionLoader<RemoteCacheSessionsLoaderContext,SessionLoader.WorkerContext,SessionLoader.WorkerResult>
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 SessionLoader.WorkerResult createFailedWorkerResult(RemoteCacheSessionsLoaderContext loaderContext, SessionLoader.WorkerContext workerContext)
SessionLoader
createFailedWorkerResult
in interface SessionLoader<RemoteCacheSessionsLoaderContext,SessionLoader.WorkerContext,SessionLoader.WorkerResult>
public SessionLoader.WorkerResult loadSessions(KeycloakSession session, RemoteCacheSessionsLoaderContext loaderContext, SessionLoader.WorkerContext ctx)
SessionLoader
loadSessions
in interface SessionLoader<RemoteCacheSessionsLoaderContext,SessionLoader.WorkerContext,SessionLoader.WorkerResult>
loaderContext
- global loaderContext object, which was already computed beforectx
- for current iterationprotected Set<Integer> getMyIspnSegments(int segment, RemoteCacheSessionsLoaderContext ctx)
public boolean isFinished(BaseCacheInitializer initializer)
SessionLoader
isFinished
in interface SessionLoader<RemoteCacheSessionsLoaderContext,SessionLoader.WorkerContext,SessionLoader.WorkerResult>
public void afterAllSessionsLoaded(BaseCacheInitializer initializer)
SessionLoader
afterAllSessionsLoaded
in interface SessionLoader<RemoteCacheSessionsLoaderContext,SessionLoader.WorkerContext,SessionLoader.WorkerResult>
protected org.infinispan.Cache getCache(KeycloakSession session)
protected org.infinispan.client.hotrod.RemoteCache getRemoteCache(KeycloakSession session)
Copyright © 2021 JBoss by Red Hat. All rights reserved.