[jboss-cvs] JBossAS SVN: r92707 - branches/Branch_5_x/tomcat/src/main/org/jboss/web/tomcat/service/session.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Aug 23 12:54:39 EDT 2009


Author: bstansberry at jboss.com
Date: 2009-08-23 12:54:38 -0400 (Sun, 23 Aug 2009)
New Revision: 92707

Modified:
   branches/Branch_5_x/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSession.java
Log:
[JBAS-7198] Replicate full session content on failover

Modified: branches/Branch_5_x/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSession.java
===================================================================
--- branches/Branch_5_x/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSession.java	2009-08-23 16:53:23 UTC (rev 92706)
+++ branches/Branch_5_x/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSession.java	2009-08-23 16:54:38 UTC (rev 92707)
@@ -150,6 +150,9 @@
    protected static final StringManager sm =
       StringManager.getManager(ClusteredSession.class.getPackage().getName());
 
+   /** Length of time we do full replication as workaround to JBCACHE-1531 */
+   private static final long FULL_REPLICATION_WINDOW_LENGTH = 5000;
+
    // ----------------------------------------------------- Instance Variables
 
    /**
@@ -374,6 +377,13 @@
    /** True if a call to activate() is needed to offset a preceding passivate() call */
    private transient boolean needsPostReplicateActivation;
    
+   /** True if a getOutgoingSessionData() should include metadata and all 
+    *  attributes no matter what. This is a workaround to JBCACHE-1531.
+    *  This flag ensures that at least one request gets full replication, whether
+    *  or not in occurs before this.fullReplicationWindow */
+   private transient boolean fullReplicationRequired = true;
+   /** End of period when we do full replication */
+   private transient long fullReplicationWindow = -1;
    
    // ------------------------------------------------------------ Constructors
 
@@ -391,6 +401,7 @@
       this.firstAccess = true;
       
       setManager(manager);
+      requireFullReplication();
    }
    
    // ---------------------------------------------------------------- Session
@@ -1070,9 +1081,19 @@
    
    protected boolean isSessionAttributeMapDirty()
    {
-      return sessionAttributesDirty;
+      return sessionAttributesDirty || isFullReplicationNeeded();
    }
    
+   protected boolean isFullReplicationNeeded()
+   {
+      if (fullReplicationRequired)
+      {
+         return true;
+      }
+      return fullReplicationRequired || 
+         (fullReplicationWindow > 0 && System.currentTimeMillis() < fullReplicationWindow);
+   }
+   
    /**
     * {@inheritDoc}
     */
@@ -1146,7 +1167,10 @@
 //      }
       
       // We are no longer outdated vis a vis distributed cache
-      outdatedTime = 0;
+      this.outdatedTime = 0;
+      
+      // Requests must publish our full state back to the cluster in case anything got dropped.
+      this.requireFullReplication();      
    }   
 
    // ------------------------------------------------------------------ Public
@@ -1171,6 +1195,12 @@
       sessionMetadataDirty = false;
       
       lastReplicated = System.currentTimeMillis();
+      
+      this.fullReplicationRequired = false;
+      if (this.fullReplicationWindow > 0 && System.currentTimeMillis() > this.fullReplicationWindow)
+      {
+         this.fullReplicationWindow = -1;
+      }
    }
    
    protected abstract O getOutgoingSessionData();
@@ -2003,5 +2033,11 @@
          manager.remove(this);
       }
    }
+   
+   private void requireFullReplication()
+   {
+      this.fullReplicationRequired = true;
+      this.fullReplicationWindow = System.currentTimeMillis() + FULL_REPLICATION_WINDOW_LENGTH;      
+   }
 
 }




More information about the jboss-cvs-commits mailing list