[Jboss-cvs] JBossAS SVN: r56307 - branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Aug 26 23:29:53 EDT 2006


Author: bstansberry at jboss.com
Date: 2006-08-26 23:29:52 -0400 (Sat, 26 Aug 2006)
New Revision: 56307

Modified:
   branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/JBossCacheManager.java
   branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/SessionReplicationContext.java
Log:
Remove expired sessions from the SessionReplicationContext

Modified: branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/JBossCacheManager.java
===================================================================
--- branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/JBossCacheManager.java	2006-08-27 03:29:25 UTC (rev 56306)
+++ branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/JBossCacheManager.java	2006-08-27 03:29:52 UTC (rev 56307)
@@ -778,6 +778,9 @@
       if (session == null 
             && !SessionReplicationContext.isSessionBound(realId, snapshotManager_))
       {
+         if (log_.isTraceEnabled())
+            log_.trace("Checking for session " + realId + " in the distributed cache");
+         
          session = loadSession(realId);
          if (session != null)
          {
@@ -788,6 +791,9 @@
       }
       else if (session != null && session.isOutdated())
       {
+         if (log_.isTraceEnabled())
+            log_.trace("Updating session " + realId + " from the distributed cache");
+         
          // Need to update it from the cache
          loadSession(realId);
       }
@@ -894,12 +900,16 @@
          }
          finally {
             SessionReplicationContext.finishLocalActivity();
+            
+            // We don't want to replicate this session at the end
+            // of the request; the removal process took care of that
+            SessionReplicationContext.unbindSession(realId, snapshotManager_);
+            
+            sessions_.remove(realId);
+            stats_.removeStats(realId);
+            activeCounter_--;
          }
-
-         sessions_.remove(realId);
-         stats_.removeStats(realId);
       }
-      activeCounter_--;
    }
 
    /**
@@ -920,16 +930,30 @@
          {
             log_.debug("Removing session from local store with id: " + realId);
          }
-         clusterSess.removeMyselfLocal();
-         sessions_.remove(realId);
-         stats_.removeStats(realId);
+
+         try {
+            // Ignore any cache notifications that our own work generates
+            SessionReplicationContext.startLocalActivity(realId);
+            clusterSess.removeMyselfLocal();
+         }
+         finally
+         {
+            SessionReplicationContext.finishLocalActivity();
+            
+            // We don't want to replicate this session at the end
+            // of the request; the removal process took care of that
+            SessionReplicationContext.unbindSession(realId, snapshotManager_);
+            
+            sessions_.remove(realId);
+            stats_.removeStats(realId);
+
+            // Update counters.
+            // It's a bit ad-hoc to do it here. But since we currently call
+            // this when session expires ...
+            expiredCounter_++;
+            activeCounter_--;
+         }
       }
-
-      // Update counters.
-      // It's a bit ad-hoc to do it here. But since we currently call
-      // this when session expires ...
-      expiredCounter_++;
-      activeCounter_--;
    }
 
    /**
@@ -1277,7 +1301,11 @@
       {
          // We weren't managing the session anyway.  But remove it
          // from the list of cached sessions we haven't loaded
-         unloadedSessions_.remove(realId);
+         if (unloadedSessions_.remove(realId) != null)
+         {
+            if (log_.isTraceEnabled())
+               log_.trace("Removed entry for session " + realId + " from unloaded session map");
+         }
       }
       else
       {

Modified: branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/SessionReplicationContext.java
===================================================================
--- branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/SessionReplicationContext.java	2006-08-27 03:29:25 UTC (rev 56306)
+++ branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/SessionReplicationContext.java	2006-08-27 03:29:52 UTC (rev 56307)
@@ -68,6 +68,15 @@
       }*/
    }
    
+   public static void unbindSession(String realId, SnapshotManager manager)
+   {
+      SessionReplicationContext ctx = getCurrentContext();
+      if (ctx != null)
+      {
+         ctx.replicatableSessions.remove(new ReplicatableSession(realId, manager));
+      }      
+   }
+   
    public static boolean isSessionBound(String realId, SnapshotManager manager)
    {
       boolean result = false;




More information about the jboss-cvs-commits mailing list