Commit e9e4371f authored by Alex Wenckus's avatar Alex Wenckus Committed by alex

Optimizations for session copy. JM-843

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@5468 b35dd754-fafc-0310-a699-88a17e54d16e
parent 0570d00e
...@@ -1019,7 +1019,7 @@ public class SessionManager extends BasicModule { ...@@ -1019,7 +1019,7 @@ public class SessionManager extends BasicModule {
*/ */
public Collection<ClientSession> getSessions() { public Collection<ClientSession> getSessions() {
List<ClientSession> allSessions = new ArrayList<ClientSession>(); List<ClientSession> allSessions = new ArrayList<ClientSession>();
copyUserSessions(allSessions); copyAllUserSessions(allSessions);
copyAnonSessions(allSessions); copyAnonSessions(allSessions);
return allSessions; return allSessions;
} }
...@@ -1032,7 +1032,7 @@ public class SessionManager extends BasicModule { ...@@ -1032,7 +1032,7 @@ public class SessionManager extends BasicModule {
if (filter.getUsername() == null) { if (filter.getUsername() == null) {
// No user id filtering // No user id filtering
copyAnonSessions(results); copyAnonSessions(results);
copyUserSessions(results); copyAllUserSessions(results);
} }
else { else {
try { try {
...@@ -1191,16 +1191,14 @@ public class SessionManager extends BasicModule { ...@@ -1191,16 +1191,14 @@ public class SessionManager extends BasicModule {
private void copyAnonSessions(List<ClientSession> sessions) { private void copyAnonSessions(List<ClientSession> sessions) {
// Add anonymous sessions // Add anonymous sessions
for (ClientSession session : anonymousSessions.values()) { sessions.addAll(anonymousSessions.values());
sessions.add(session);
}
} }
private void copyUserSessions(List<ClientSession> sessions) { private void copyAllUserSessions(List<ClientSession> sessions) {
// Get a copy of the sessions from all users // Get a copy of the sessions from all users
for (String username : getSessionUsers()) { for(SessionMap sessionMap : this.sessions.values()) {
for (ClientSession session : getSessions(username)) { if(sessionMap != null) {
sessions.add(session); sessions.addAll(sessionMap.getSessions());
} }
} }
} }
...@@ -1209,14 +1207,12 @@ public class SessionManager extends BasicModule { ...@@ -1209,14 +1207,12 @@ public class SessionManager extends BasicModule {
// Get a copy of the sessions from all users // Get a copy of the sessions from all users
SessionMap sessionMap = sessions.get(username); SessionMap sessionMap = sessions.get(username);
if (sessionMap != null) { if (sessionMap != null) {
for (ClientSession session : sessionMap.getSessions()) { sessionList.addAll(sessionMap.getSessions());
sessionList.add(session);
}
} }
} }
public Iterator getAnonymousSessions() { public Iterator getAnonymousSessions() {
return Arrays.asList(anonymousSessions.values().toArray()).iterator(); return Collections.unmodifiableCollection(anonymousSessions.values()).iterator();
} }
public Collection<ClientSession> getSessions(String username) { public Collection<ClientSession> getSessions(String username) {
......
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