Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions server/src/main/java/com/cloud/api/ApiSessionListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,12 @@ public class ApiSessionListener implements HttpSessionListener, ServletRequestLi
public static final Logger LOGGER = Logger.getLogger(ApiSessionListener.class.getName());
private static final String ATTRIBUTE_NAME = "SessionCounter";
private static Map<HttpSession, Object> sessions = new ConcurrentHashMap<>();
private static long sessionCount;

public ApiSessionListener() {
sessionCount = 0;
}

/**
* @return the internal adminstered session count
*/
public static long getSessionCount() {
return sessionCount;
return sessions.size();
}

/**
Expand All @@ -57,17 +52,15 @@ public void sessionCreated(HttpSessionEvent event) {
synchronized (this) {
HttpSession session = event.getSession();
sessions.put(session, event.getSource());
sessionCount++;
}
LOGGER.debug("Sessions count: " + sessions);
LOGGER.debug("Sessions count: " + getSessionCount());
}
public void sessionDestroyed(HttpSessionEvent event) {
LOGGER.debug("Session destroyed by Id : " + event.getSession().getId() + " , session: " + event.getSession().toString() + " , source: " + event.getSource().toString() + " , event: " + event.toString());
synchronized (this) {
sessionCount--;
sessions.remove(event.getSession());
}
LOGGER.debug("Sessions count: " + sessions);
LOGGER.debug("Sessions count: " + getSessionCount());
}

@Override
Expand Down