Search in sources :

Example 16 with InfinispanConnectionProvider

use of org.keycloak.connections.infinispan.InfinispanConnectionProvider 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)

Aggregations

InfinispanConnectionProvider (org.keycloak.connections.infinispan.InfinispanConnectionProvider)16 Cache (org.infinispan.Cache)5 SessionEntityWrapper (org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper)5 RemoteCache (org.infinispan.client.hotrod.RemoteCache)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Test (org.junit.Test)3 KeycloakModelTest (org.keycloak.testsuite.model.KeycloakModelTest)3 LinkedList (java.util.LinkedList)2 List (java.util.List)2 UUID (java.util.UUID)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 KeycloakSession (org.keycloak.models.KeycloakSession)2 KeycloakSessionTask (org.keycloak.models.KeycloakSessionTask)2 RealmModel (org.keycloak.models.RealmModel)2 UserModel (org.keycloak.models.UserModel)2 LoginFailureKey (org.keycloak.models.sessions.infinispan.entities.LoginFailureKey)2 InfinispanCacheInitializer (org.keycloak.models.sessions.infinispan.initializer.InfinispanCacheInitializer)2 RemoteCacheSessionsLoader (org.keycloak.models.sessions.infinispan.remotestore.RemoteCacheSessionsLoader)2 SessionTimeouts (org.keycloak.models.sessions.infinispan.util.SessionTimeouts)2 RequireProvider (org.keycloak.testsuite.model.RequireProvider)2