Commit 67f9ab65 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Removed couonter of authenticated sessions.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8671 b35dd754-fafc-0310-a699-88a17e54d16e
parent 80dea18a
...@@ -68,10 +68,6 @@ public class SessionManager extends BasicModule implements ClusterEventListener ...@@ -68,10 +68,6 @@ public class SessionManager extends BasicModule implements ClusterEventListener
* after the user became available. * after the user became available.
*/ */
private final AtomicInteger connectionsCounter = new AtomicInteger(0); private final AtomicInteger connectionsCounter = new AtomicInteger(0);
/**
* Counter of anonymous and non-anonymous user sessions.
*/
private final AtomicInteger userSessionsCounter = new AtomicInteger(0);
/** /**
* Cache (unlimited, never expire) that holds external component sessions. * Cache (unlimited, never expire) that holds external component sessions.
...@@ -513,10 +509,7 @@ public class SessionManager extends BasicModule implements ClusterEventListener ...@@ -513,10 +509,7 @@ public class SessionManager extends BasicModule implements ClusterEventListener
// Remove the pre-Authenticated session but remember to use the temporary ID as the key // Remove the pre-Authenticated session but remember to use the temporary ID as the key
localSessionManager.getPreAuthenticatedSessions().remove(session.getStreamID().toString()); localSessionManager.getPreAuthenticatedSessions().remove(session.getStreamID().toString());
// Add session to the routing table (routing table will know session is not available yet) // Add session to the routing table (routing table will know session is not available yet)
if (routingTable.addClientRoute(session.getAddress(), session)) { routingTable.addClientRoute(session.getAddress(), session);
// Increment counter of authenticated sessions
userSessionsCounter.incrementAndGet();
}
SessionEventDispatcher.EventType event = session.getAuthToken().isAnonymous() ? SessionEventDispatcher.EventType event = session.getAuthToken().isAnonymous() ?
SessionEventDispatcher.EventType.anonymous_session_created : SessionEventDispatcher.EventType.anonymous_session_created :
SessionEventDispatcher.EventType.session_created; SessionEventDispatcher.EventType.session_created;
...@@ -833,16 +826,16 @@ public class SessionManager extends BasicModule implements ClusterEventListener ...@@ -833,16 +826,16 @@ public class SessionManager extends BasicModule implements ClusterEventListener
* @return number of client sessions that are connected to the server. * @return number of client sessions that are connected to the server.
*/ */
public int getConnectionsCount(boolean onlyLocal) { public int getConnectionsCount(boolean onlyLocal) {
if (onlyLocal) {
return connectionsCounter.get();
}
Collection<Object> results = CacheFactory.doSynchronousClusterTask(new GetSessionsCountTask(false), false);
int total = connectionsCounter.get(); int total = connectionsCounter.get();
for (Object result : results) { if (!onlyLocal) {
if (result == null) { Collection<Object> results =
continue; CacheFactory.doSynchronousClusterTask(new GetSessionsCountTask(false), false);
for (Object result : results) {
if (result == null) {
continue;
}
total = total + (Integer) result;
} }
total = total + (Integer) result;
} }
return total; return total;
} }
...@@ -855,16 +848,16 @@ public class SessionManager extends BasicModule implements ClusterEventListener ...@@ -855,16 +848,16 @@ public class SessionManager extends BasicModule implements ClusterEventListener
* @return number of client sessions that are authenticated with the server. * @return number of client sessions that are authenticated with the server.
*/ */
public int getUserSessionsCount(boolean onlyLocal) { public int getUserSessionsCount(boolean onlyLocal) {
if (onlyLocal) { int total = routingTable.getClientsRoutes(true).size();
return userSessionsCounter.get(); if (!onlyLocal) {
} Collection<Object> results =
Collection<Object> results = CacheFactory.doSynchronousClusterTask(new GetSessionsCountTask(true), false); CacheFactory.doSynchronousClusterTask(new GetSessionsCountTask(true), false);
int total = userSessionsCounter.get(); for (Object result : results) {
for (Object result : results) { if (result == null) {
if (result == null) { continue;
continue; }
total = total + (Integer) result;
} }
total = total + (Integer) result;
} }
return total; return total;
} }
...@@ -1046,10 +1039,6 @@ public class SessionManager extends BasicModule implements ClusterEventListener ...@@ -1046,10 +1039,6 @@ public class SessionManager extends BasicModule implements ClusterEventListener
router.route(offline); router.route(offline);
} }
if (removed || preauth_removed) { if (removed || preauth_removed) {
if (removed) {
// Decrement number of authenticated sessions (of anonymous and non-anonymous users)
userSessionsCounter.decrementAndGet();
}
// Decrement the counter of user sessions // Decrement the counter of user sessions
connectionsCounter.decrementAndGet(); connectionsCounter.decrementAndGet();
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment