Search in sources :

Example 1 with InfinispanCacheInitializer

use of org.keycloak.models.sessions.infinispan.initializer.InfinispanCacheInitializer in project keycloak by keycloak.

the class InfinispanUserLoginFailureProviderFactory method loadLoginFailuresFromRemoteCaches.

private void loadLoginFailuresFromRemoteCaches(final KeycloakSessionFactory sessionFactory, String cacheName, final int sessionsPerSegment, final int maxErrors) {
    log.debugf("Check pre-loading sessions from remote cache '%s'", cacheName);
    KeycloakModelUtils.runJobInTransaction(sessionFactory, new KeycloakSessionTask() {

        @Override
        public void run(KeycloakSession session) {
            InfinispanConnectionProvider connections = session.getProvider(InfinispanConnectionProvider.class);
            Cache<String, Serializable> workCache = connections.getCache(InfinispanConnectionProvider.WORK_CACHE_NAME);
            InfinispanCacheInitializer initializer = new InfinispanCacheInitializer(sessionFactory, workCache, new RemoteCacheSessionsLoader(cacheName, sessionsPerSegment), "remoteCacheLoad::" + cacheName, sessionsPerSegment, maxErrors);
            initializer.initCache();
            initializer.loadSessions();
        }
    });
    log.debugf("Pre-loading login failures from remote cache '%s' finished", cacheName);
}
Also used : KeycloakSessionTask(org.keycloak.models.KeycloakSessionTask) KeycloakSession(org.keycloak.models.KeycloakSession) InfinispanConnectionProvider(org.keycloak.connections.infinispan.InfinispanConnectionProvider) InfinispanCacheInitializer(org.keycloak.models.sessions.infinispan.initializer.InfinispanCacheInitializer) RemoteCacheSessionsLoader(org.keycloak.models.sessions.infinispan.remotestore.RemoteCacheSessionsLoader) Cache(org.infinispan.Cache) RemoteCache(org.infinispan.client.hotrod.RemoteCache)

Example 2 with InfinispanCacheInitializer

use of org.keycloak.models.sessions.infinispan.initializer.InfinispanCacheInitializer in project keycloak by keycloak.

the class InfinispanUserSessionProviderFactory method loadSessionsFromRemoteCache.

private void loadSessionsFromRemoteCache(final KeycloakSessionFactory sessionFactory, String cacheName, final int sessionsPerSegment, final int maxErrors) {
    log.debugf("Check pre-loading sessions from remote cache '%s'", cacheName);
    KeycloakModelUtils.runJobInTransaction(sessionFactory, new KeycloakSessionTask() {

        @Override
        public void run(KeycloakSession session) {
            InfinispanConnectionProvider connections = session.getProvider(InfinispanConnectionProvider.class);
            Cache<String, Serializable> workCache = connections.getCache(InfinispanConnectionProvider.WORK_CACHE_NAME);
            InfinispanCacheInitializer initializer = new InfinispanCacheInitializer(sessionFactory, workCache, new RemoteCacheSessionsLoader(cacheName, sessionsPerSegment), "remoteCacheLoad::" + cacheName, sessionsPerSegment, maxErrors);
            initializer.initCache();
            initializer.loadSessions();
        }
    });
    log.debugf("Pre-loading sessions from remote cache '%s' finished", cacheName);
}
Also used : KeycloakSessionTask(org.keycloak.models.KeycloakSessionTask) KeycloakSession(org.keycloak.models.KeycloakSession) InfinispanConnectionProvider(org.keycloak.connections.infinispan.InfinispanConnectionProvider) InfinispanCacheInitializer(org.keycloak.models.sessions.infinispan.initializer.InfinispanCacheInitializer) RemoteCacheSessionsLoader(org.keycloak.models.sessions.infinispan.remotestore.RemoteCacheSessionsLoader) Cache(org.infinispan.Cache) RemoteCache(org.infinispan.client.hotrod.RemoteCache)

Aggregations

Cache (org.infinispan.Cache)2 RemoteCache (org.infinispan.client.hotrod.RemoteCache)2 InfinispanConnectionProvider (org.keycloak.connections.infinispan.InfinispanConnectionProvider)2 KeycloakSession (org.keycloak.models.KeycloakSession)2 KeycloakSessionTask (org.keycloak.models.KeycloakSessionTask)2 InfinispanCacheInitializer (org.keycloak.models.sessions.infinispan.initializer.InfinispanCacheInitializer)2 RemoteCacheSessionsLoader (org.keycloak.models.sessions.infinispan.remotestore.RemoteCacheSessionsLoader)2