Hi,

I want to track all the active sessions of a tomcat 5.5 cluster. 
Particularly, I want to host a page on each cluster member which will
display all the sessions active on its cluster.

So I want to see a list of :
session-id, user-name, jvmRoute (of member to which this session is sticky
to).

What I have tried is :
Whenever a new session is created I create an object which implements
HttpSessionBindingListener 
and put in the session.

    public void valueBound(HttpSessionBindingEvent event) {
        synchronized(ActiveSessions.ACTIVE_SESSIONS) {
            HttpSession session = event.getSession();
            ActiveSessions.ACTIVE_SESSIONS.add(this);
            System.out.println("VV Registered Session : " + this);
            System.out.println("VV Active Sessions count : " +
ActiveSessions.ACTIVE_SESSIONS.size() + " :: Active Sessions : " +
ActiveSessions.ACTIVE_SESSIONS);
        }
    }

    public void valueUnbound(HttpSessionBindingEvent event) {
        synchronized(ActiveSessions.ACTIVE_SESSIONS) {
            long expiredAt = System.currentTimeMillis();
            ActiveSessions.ACTIVE_SESSIONS.remove(this);

            // TODO : bookkeeping of expired sessions, write to a separate
log file.
            System.out.println("VV Deregistered Session : " + this);

            System.out.println("Session Expired : " + this + " Session
lasted from : " + createdAt + "-" + expiredAt);

            System.out.println("VV Active Sessions count : " +
ActiveSessions.ACTIVE_SESSIONS.size() + " :: Active Sessions : " +
ActiveSessions.ACTIVE_SESSIONS);
        }
    }


Things work fine except for following case :

Say clusterMember1 is down when a new session is created at clusterMember2.

When clusterMember1 comes up it syncs it session state with clusterMember2
but valueBound() is 
never called in clusterMember1's JVM so I am unable to register this session
in clusterMember1's 
ACTIVE_SESSIONS list. Because of this my ACTIVE_SESSIONS list is not in sync
across cluster members.

Is this correct that valueBound will be called on only the cluster members
which were alive when the 
object was put in the session ?

Is there any other way I can track all active session of a cluster ?

Thanks,
Vinod
-- 
View this message in context: 
http://www.nabble.com/Tracking-active-session-in-a-tomcat-cluster-tf4278998.html#a12179367
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to