Search in sources :

Example 1 with Mappers

use of org.keycloak.models.sessions.infinispan.stream.Mappers in project keycloak by keycloak.

the class InfinispanUserSessionProvider method getActiveClientSessionStats.

@Override
public Map<String, Long> getActiveClientSessionStats(RealmModel realm, boolean offline) {
    if (offline && loadOfflineSessionsFromDatabase) {
        UserSessionPersisterProvider persister = session.getProvider(UserSessionPersisterProvider.class);
        return persister.getUserSessionsCountsByClients(realm, true);
    }
    Cache<String, SessionEntityWrapper<UserSessionEntity>> cache = getCache(offline);
    cache = CacheDecorators.skipCacheLoaders(cache);
    return cache.entrySet().stream().filter(UserSessionPredicate.create(realm.getId())).map(Mappers.authClientSessionSetMapper()).flatMap((Serializable & Function<Set<String>, Stream<? extends String>>) Mappers::toStream).collect(CacheCollectors.serializableCollector(() -> Collectors.groupingBy(Function.identity(), Collectors.counting())));
}
Also used : UserSessionPersisterProvider(org.keycloak.models.session.UserSessionPersisterProvider) Set(java.util.Set) Mappers(org.keycloak.models.sessions.infinispan.stream.Mappers) Stream(java.util.stream.Stream) StreamsUtil.paginatedStream(org.keycloak.utils.StreamsUtil.paginatedStream) SessionEntityWrapper(org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper)

Aggregations

Set (java.util.Set)1 Stream (java.util.stream.Stream)1 UserSessionPersisterProvider (org.keycloak.models.session.UserSessionPersisterProvider)1 SessionEntityWrapper (org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper)1 Mappers (org.keycloak.models.sessions.infinispan.stream.Mappers)1 StreamsUtil.paginatedStream (org.keycloak.utils.StreamsUtil.paginatedStream)1