Implement allocation-friendly method to get user count in SimpUserRegistry

SPR-14930
This commit is contained in:
Christoph Dreis
2016-11-21 21:02:10 +01:00
parent da63898d5f
commit a929e9ccaa
6 changed files with 37 additions and 10 deletions

View File

@@ -135,6 +135,16 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
return result;
}
@Override
public int getUserCount() {
int userCount = 0;
for (UserRegistrySnapshot registry : this.remoteRegistries.values()) {
userCount += registry.getUserMap().size();
}
userCount += this.localRegistry.getUserCount();
return userCount;
}
@Override
public Set<SimpSubscription> findSubscriptions(SimpSubscriptionMatcher matcher) {
Set<SimpSubscription> result = new HashSet<>();

View File

@@ -40,6 +40,13 @@ public interface SimpUserRegistry {
*/
Set<SimpUser> getUsers();
/**
* Return the count of all connected users.
* @return the connected user count.
* @since 4.3.5
*/
int getUserCount();
/**
* Find subscriptions with the given matcher.
* @param matcher the matcher to use