Remove offline sessions timeouts adjusters as with persistent session we have bounded caches and it is no longer necessary to adjust time in caches
Closes #29140 Signed-off-by: Michal Hajas <mhajas@redhat.com>
This commit is contained in:
parent
8d4d5c1c54
commit
7c427e8d38
3 changed files with 9 additions and 19 deletions
|
@ -132,8 +132,6 @@ public class InfinispanUserSessionProviderFactory implements UserSessionProvider
|
|||
offlineSessionsCache,
|
||||
clientSessionCache,
|
||||
offlineClientSessionsCache,
|
||||
this::deriveOfflineSessionCacheEntryLifespanMs,
|
||||
this::deriveOfflineClientSessionCacheEntryLifespanOverrideMs,
|
||||
serializerSession,
|
||||
serializerOfflineSession,
|
||||
serializerClientSession,
|
||||
|
|
|
@ -116,10 +116,6 @@ public class PersistentUserSessionProvider implements UserSessionProvider, Sessi
|
|||
protected final RemoteCacheInvoker remoteCacheInvoker;
|
||||
protected final InfinispanKeyGenerator keyGenerator;
|
||||
|
||||
protected final SessionFunction<UserSessionEntity> offlineSessionCacheEntryLifespanAdjuster;
|
||||
|
||||
protected final SessionFunction<AuthenticatedClientSessionEntity> offlineClientSessionCacheEntryLifespanAdjuster;
|
||||
|
||||
public PersistentUserSessionProvider(KeycloakSession session,
|
||||
RemoteCacheInvoker remoteCacheInvoker,
|
||||
CrossDCLastSessionRefreshStore lastSessionRefreshStore,
|
||||
|
@ -130,8 +126,6 @@ public class PersistentUserSessionProvider implements UserSessionProvider, Sessi
|
|||
Cache<String, SessionEntityWrapper<UserSessionEntity>> offlineSessionCache,
|
||||
Cache<UUID, SessionEntityWrapper<AuthenticatedClientSessionEntity>> clientSessionCache,
|
||||
Cache<UUID, SessionEntityWrapper<AuthenticatedClientSessionEntity>> offlineClientSessionCache,
|
||||
SessionFunction<UserSessionEntity> offlineSessionCacheEntryLifespanAdjuster,
|
||||
SessionFunction<AuthenticatedClientSessionEntity> offlineClientSessionCacheEntryLifespanAdjuster,
|
||||
SerializeExecutionsByKey<String> serializerSession,
|
||||
SerializeExecutionsByKey<String> serializerOfflineSession,
|
||||
SerializeExecutionsByKey<UUID> serializerClientSession,
|
||||
|
@ -150,12 +144,12 @@ public class PersistentUserSessionProvider implements UserSessionProvider, Sessi
|
|||
|
||||
this.sessionTx = new UserSessionPersistentChangelogBasedTransaction(session, sessionCache, remoteCacheInvoker, SessionTimeouts::getUserSessionLifespanMs, SessionTimeouts::getUserSessionMaxIdleMs, false, serializerSession,
|
||||
asyncQueuePersistentUpdate);
|
||||
this.offlineSessionTx = new UserSessionPersistentChangelogBasedTransaction(session, offlineSessionCache, remoteCacheInvoker, offlineSessionCacheEntryLifespanAdjuster, SessionTimeouts::getOfflineSessionMaxIdleMs, true, serializerOfflineSession,
|
||||
this.offlineSessionTx = new UserSessionPersistentChangelogBasedTransaction(session, offlineSessionCache, remoteCacheInvoker, SessionTimeouts::getUserSessionLifespanMs, SessionTimeouts::getOfflineSessionMaxIdleMs, true, serializerOfflineSession,
|
||||
asyncQueuePersistentUpdate);
|
||||
|
||||
this.clientSessionTx = new ClientSessionPersistentChangelogBasedTransaction(session, clientSessionCache, remoteCacheInvoker, SessionTimeouts::getClientSessionLifespanMs, SessionTimeouts::getClientSessionMaxIdleMs, false, keyGenerator, sessionTx, serializerClientSession,
|
||||
asyncQueuePersistentUpdate);
|
||||
this.offlineClientSessionTx = new ClientSessionPersistentChangelogBasedTransaction(session, offlineClientSessionCache, remoteCacheInvoker, offlineClientSessionCacheEntryLifespanAdjuster, SessionTimeouts::getOfflineClientSessionMaxIdleMs, true, keyGenerator, offlineSessionTx, serializerOfflineClientSession,
|
||||
this.offlineClientSessionTx = new ClientSessionPersistentChangelogBasedTransaction(session, offlineClientSessionCache, remoteCacheInvoker, SessionTimeouts::getClientSessionLifespanMs, SessionTimeouts::getOfflineClientSessionMaxIdleMs, true, keyGenerator, offlineSessionTx, serializerOfflineClientSession,
|
||||
asyncQueuePersistentUpdate);
|
||||
|
||||
this.clusterEventsSenderTx = new SessionEventsSenderTransaction(session);
|
||||
|
@ -165,8 +159,6 @@ public class PersistentUserSessionProvider implements UserSessionProvider, Sessi
|
|||
this.persisterLastSessionRefreshStore = persisterLastSessionRefreshStore;
|
||||
this.remoteCacheInvoker = remoteCacheInvoker;
|
||||
this.keyGenerator = keyGenerator;
|
||||
this.offlineSessionCacheEntryLifespanAdjuster = offlineSessionCacheEntryLifespanAdjuster;
|
||||
this.offlineClientSessionCacheEntryLifespanAdjuster = offlineClientSessionCacheEntryLifespanAdjuster;
|
||||
|
||||
session.getTransactionManager().enlistAfterCompletion(clusterEventsSenderTx);
|
||||
session.getTransactionManager().enlistAfterCompletion(sessionTx);
|
||||
|
@ -838,7 +830,7 @@ public class PersistentUserSessionProvider implements UserSessionProvider, Sessi
|
|||
Cache<String, SessionEntityWrapper<UserSessionEntity>> cache = CacheDecorators.skipCacheLoadersIfRemoteStoreIsEnabled(getCache(offline));
|
||||
|
||||
sessionsById = importSessionsWithExpiration(sessionsById, cache,
|
||||
offline ? offlineSessionCacheEntryLifespanAdjuster : SessionTimeouts::getUserSessionLifespanMs,
|
||||
offline ? SessionTimeouts::getOfflineSessionLifespanMs : SessionTimeouts::getUserSessionLifespanMs,
|
||||
offline ? SessionTimeouts::getOfflineSessionMaxIdleMs : SessionTimeouts::getUserSessionMaxIdleMs);
|
||||
|
||||
if (sessionsById.isEmpty()) {
|
||||
|
@ -853,7 +845,7 @@ public class PersistentUserSessionProvider implements UserSessionProvider, Sessi
|
|||
.collect(Collectors.toMap(sessionEntityWrapper -> sessionEntityWrapper.getEntity().getId(), Function.identity()));
|
||||
|
||||
importSessionsWithExpiration(sessionsByIdForTransport, remoteCache,
|
||||
offline ? offlineSessionCacheEntryLifespanAdjuster : SessionTimeouts::getUserSessionLifespanMs,
|
||||
offline ? SessionTimeouts::getOfflineSessionLifespanMs : SessionTimeouts::getUserSessionLifespanMs,
|
||||
offline ? SessionTimeouts::getOfflineSessionMaxIdleMs : SessionTimeouts::getUserSessionMaxIdleMs);
|
||||
}
|
||||
|
||||
|
@ -862,7 +854,7 @@ public class PersistentUserSessionProvider implements UserSessionProvider, Sessi
|
|||
CacheDecorators.skipCacheLoadersIfRemoteStoreIsEnabled(offline ? offlineClientSessionCache : clientSessionCache);
|
||||
|
||||
importSessionsWithExpiration(clientSessionsById, clientSessCache,
|
||||
offline ? offlineClientSessionCacheEntryLifespanAdjuster : SessionTimeouts::getClientSessionLifespanMs,
|
||||
offline ? SessionTimeouts::getOfflineClientSessionLifespanMs : SessionTimeouts::getClientSessionLifespanMs,
|
||||
offline ? SessionTimeouts::getOfflineClientSessionMaxIdleMs : SessionTimeouts::getClientSessionMaxIdleMs);
|
||||
|
||||
// put all entities to the remoteCache (if exists)
|
||||
|
@ -873,7 +865,7 @@ public class PersistentUserSessionProvider implements UserSessionProvider, Sessi
|
|||
.collect(Collectors.toMap(sessionEntityWrapper -> sessionEntityWrapper.getEntity().getId(), Function.identity()));
|
||||
|
||||
importSessionsWithExpiration(sessionsByIdForTransport, remoteCacheClientSessions,
|
||||
offline ? offlineClientSessionCacheEntryLifespanAdjuster : SessionTimeouts::getClientSessionLifespanMs,
|
||||
offline ? SessionTimeouts::getOfflineClientSessionLifespanMs : SessionTimeouts::getClientSessionLifespanMs,
|
||||
offline ? SessionTimeouts::getOfflineClientSessionMaxIdleMs : SessionTimeouts::getClientSessionMaxIdleMs);
|
||||
}
|
||||
|
||||
|
@ -965,7 +957,7 @@ public class PersistentUserSessionProvider implements UserSessionProvider, Sessi
|
|||
|
||||
if (checkExpiration) {
|
||||
SessionFunction<AuthenticatedClientSessionEntity> lifespanChecker = offline
|
||||
? offlineClientSessionCacheEntryLifespanAdjuster : SessionTimeouts::getClientSessionLifespanMs;
|
||||
? SessionTimeouts::getOfflineClientSessionLifespanMs : SessionTimeouts::getClientSessionLifespanMs;
|
||||
SessionFunction<AuthenticatedClientSessionEntity> idleTimeoutChecker = offline
|
||||
? SessionTimeouts::getOfflineClientSessionMaxIdleMs : SessionTimeouts::getClientSessionMaxIdleMs;
|
||||
if (idleTimeoutChecker.apply(sessionToImportInto.getRealm(), clientSession.getClient(), entity) == SessionTimeouts.ENTRY_EXPIRED_FLAG
|
||||
|
|
|
@ -481,8 +481,8 @@ public class UserSessionProviderOfflineModelTest extends KeycloakModelTest {
|
|||
public void testOfflineSessionLifespanOverride() {
|
||||
// skip the test for CrossDC
|
||||
Assume.assumeFalse(Objects.equals(CONFIG.scope("connectionsInfinispan.default").get("remoteStoreEnabled"), "true"));
|
||||
// As we don't put things in the embedded cache, the test will fail as the number of entries will always be 0.
|
||||
Assume.assumeFalse(Profile.isFeatureEnabled(Profile.Feature.PERSISTENT_USER_SESSIONS_NO_CACHE));
|
||||
// As offline session's timeout is not overriden when PERSISTENT_USER_SESSIONS is enabled
|
||||
Assume.assumeFalse(Profile.isFeatureEnabled(Profile.Feature.PERSISTENT_USER_SESSIONS));
|
||||
|
||||
createOfflineSessions("user1", 2, new LinkedList<>(), new LinkedList<>());
|
||||
|
||||
|
|
Loading…
Reference in a new issue