Remove expired objects from cache cluster instead of local only
This commit is contained in:
1 parent
2e22dcfc47
commit
c64ecb1ab8
2 files changed
+13
-15
No files matched your search
+1
-1
@@ -120,7 +120,7 @@ public class InfinispanAuthenticationSessionProvider implements AuthenticationSe
|
||||
while (itr.hasNext()) {
|
||||
counter++;
|
||||
RootAuthenticationSessionEntity entity = itr.next().getValue();
|
||||
tx.remove(CacheDecorators.localCache(cache), entity.getId());
|
||||
tx.remove(cache, entity.getId());
|
||||
}
|
||||
|
||||
log.debugf("Removed %d expired authentication sessions for realm '%s'", counter, realm.getName());
|
||||
|
||||
+12
-14
@@ -476,8 +476,6 @@ public class InfinispanUserSessionProvider implements UserSessionProvider {
|
||||
|
||||
// Each cluster node cleanups just local sessions, which are those owned by itself (+ few more taking l1 cache into account)
|
||||
Cache<String, SessionEntityWrapper<UserSessionEntity>> localCache = CacheDecorators.localCache(sessionCache);
|
||||
Cache<UUID, SessionEntityWrapper<AuthenticatedClientSessionEntity>> localClientSessionCache = CacheDecorators.localCache(clientSessionCache);
|
||||
|
||||
Cache<String, SessionEntityWrapper<UserSessionEntity>> localCacheStoreIgnore = CacheDecorators.skipCacheLoaders(localCache);
|
||||
|
||||
final AtomicInteger userSessionsSize = new AtomicInteger();
|
||||
@@ -495,12 +493,12 @@ public class InfinispanUserSessionProvider implements UserSessionProvider {
|
||||
public void accept(UserSessionEntity userSessionEntity) {
|
||||
userSessionsSize.incrementAndGet();
|
||||
|
||||
Future future = localCache.removeAsync(userSessionEntity.getId());
|
||||
Future future = sessionCache.removeAsync(userSessionEntity.getId());
|
||||
futures.addTask(future);
|
||||
|
||||
userSessionEntity.getAuthenticatedClientSessions().forEach((clientUUID, clientSessionId) -> {
|
||||
clientSessionsSize.incrementAndGet();
|
||||
Future f = localClientSessionCache.removeAsync(clientSessionId);
|
||||
Future f = clientSessionCache.removeAsync(clientSessionId);
|
||||
futures.addTask(f);
|
||||
});
|
||||
}
|
||||
@@ -508,9 +506,10 @@ public class InfinispanUserSessionProvider implements UserSessionProvider {
|
||||
});
|
||||
|
||||
// Removing detached clientSessions. Ignore remoteStore for stream iteration. But we will invoke remoteStore for clientSession removal propagate
|
||||
Cache<UUID, SessionEntityWrapper<AuthenticatedClientSessionEntity>> localCacheStoreIgnoreClientSessionCache = CacheDecorators.localCache(localClientSessionCache);
|
||||
Cache<UUID, SessionEntityWrapper<AuthenticatedClientSessionEntity>> localClientSessionCache = CacheDecorators.localCache(clientSessionCache);
|
||||
Cache<UUID, SessionEntityWrapper<AuthenticatedClientSessionEntity>> localClientSessionCacheStoreIgnore = CacheDecorators.skipCacheLoaders(localClientSessionCache);
|
||||
|
||||
localCacheStoreIgnoreClientSessionCache
|
||||
localClientSessionCacheStoreIgnore
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter(AuthenticatedClientSessionPredicate.create(realm.getId()).expired(expired))
|
||||
@@ -521,7 +520,7 @@ public class InfinispanUserSessionProvider implements UserSessionProvider {
|
||||
public void accept(AuthenticatedClientSessionEntity clientSessionEntity) {
|
||||
clientSessionsSize.incrementAndGet();
|
||||
|
||||
Future future = localClientSessionCache.removeAsync(clientSessionEntity.getId());
|
||||
Future future = clientSessionCache.removeAsync(clientSessionEntity.getId());
|
||||
futures.addTask(future);
|
||||
}
|
||||
|
||||
@@ -539,7 +538,6 @@ public class InfinispanUserSessionProvider implements UserSessionProvider {
|
||||
|
||||
// Each cluster node cleanups just local sessions, which are those owned by himself (+ few more taking l1 cache into account)
|
||||
Cache<String, SessionEntityWrapper<UserSessionEntity>> localCache = CacheDecorators.localCache(offlineSessionCache);
|
||||
Cache<UUID, SessionEntityWrapper<AuthenticatedClientSessionEntity>> localClientSessionCache = CacheDecorators.localCache(offlineClientSessionCache);
|
||||
|
||||
UserSessionPredicate predicate = UserSessionPredicate.create(realm.getId()).expired(null, expiredOffline);
|
||||
|
||||
@@ -562,11 +560,11 @@ public class InfinispanUserSessionProvider implements UserSessionProvider {
|
||||
public void accept(UserSessionEntity userSessionEntity) {
|
||||
userSessionsSize.incrementAndGet();
|
||||
|
||||
Future future = localCache.removeAsync(userSessionEntity.getId());
|
||||
Future future = offlineSessionCache.removeAsync(userSessionEntity.getId());
|
||||
futures.addTask(future);
|
||||
userSessionEntity.getAuthenticatedClientSessions().forEach((clientUUID, clientSessionId) -> {
|
||||
clientSessionsSize.incrementAndGet();
|
||||
Future f = localClientSessionCache.removeAsync(clientSessionId);
|
||||
Future f = offlineClientSessionCache.removeAsync(clientSessionId);
|
||||
futures.addTask(f);
|
||||
});
|
||||
|
||||
@@ -575,11 +573,11 @@ public class InfinispanUserSessionProvider implements UserSessionProvider {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Removing detached clientSessions. Ignore remoteStore for stream iteration. But we will invoke remoteStore for clientSession removal propagate
|
||||
Cache<UUID, SessionEntityWrapper<AuthenticatedClientSessionEntity>> localCacheStoreIgnoreClientSessionCache = CacheDecorators.localCache(localClientSessionCache);
|
||||
Cache<UUID, SessionEntityWrapper<AuthenticatedClientSessionEntity>> localClientSessionCache = CacheDecorators.localCache(offlineClientSessionCache);
|
||||
Cache<UUID, SessionEntityWrapper<AuthenticatedClientSessionEntity>> localClientSessionCacheStoreIgnore = CacheDecorators.skipCacheLoaders(localClientSessionCache);
|
||||
|
||||
localCacheStoreIgnoreClientSessionCache
|
||||
localClientSessionCacheStoreIgnore
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter(AuthenticatedClientSessionPredicate.create(realm.getId()).expired(expiredOffline))
|
||||
@@ -590,7 +588,7 @@ public class InfinispanUserSessionProvider implements UserSessionProvider {
|
||||
public void accept(AuthenticatedClientSessionEntity clientSessionEntity) {
|
||||
clientSessionsSize.incrementAndGet();
|
||||
|
||||
Future future = localClientSessionCache.removeAsync(clientSessionEntity.getId());
|
||||
Future future = offlineClientSessionCache.removeAsync(clientSessionEntity.getId());
|
||||
futures.addTask(future);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user