Interface SessionLoader<LOADER_CONTEXT extends SessionLoader.LoaderContext,​WORKER_CONTEXT extends SessionLoader.WorkerContext,​WORKER_RESULT extends SessionLoader.WorkerResult>

    • Method Detail

      • init

        void 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 -
      • computeLoaderContext

        LOADER_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:
      • 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 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:
      • 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 before
        workerContext - for current iteration
        Returns:
      • createFailedWorkerResult

        WORKER_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:
      • isFinished

        boolean 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:
      • afterAllSessionsLoaded

        void afterAllSessionsLoaded​(BaseCacheInitializer initializer)
        Callback triggered on cluster coordinator once it recognize that all sessions were successfully loaded
        Parameters:
        initializer -