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())));
}
Aggregations