You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by rj...@apache.org on 2009/09/23 13:24:23 UTC

svn commit: r818061 - in /tomcat/tc5.5.x/trunk: ./ container/modules/cluster/src/share/org/apache/catalina/cluster/session/ container/webapps/docs/

Author: rjung
Date: Wed Sep 23 11:24:22 2009
New Revision: 818061

URL: http://svn.apache.org/viewvc?rev=818061&view=rev
Log:
DeltaManager needs to replicate changed attributes even if session
gets invalidated. Otherwise session listeners will not see the right
data on the secondary nodes.

Ported from r812427 of OACC.

Modified:
    tomcat/tc5.5.x/trunk/STATUS.txt
    tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java
    tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaSession.java
    tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml

Modified: tomcat/tc5.5.x/trunk/STATUS.txt
URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/STATUS.txt?rev=818061&r1=818060&r2=818061&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/STATUS.txt (original)
+++ tomcat/tc5.5.x/trunk/STATUS.txt Wed Sep 23 11:24:22 2009
@@ -94,15 +94,6 @@
   +1: markt
   -1: 
 
-* Fix cluster replication problem: session expiration uses a replication
-  shortcut, so that attributes changed immediately before invalidation do
-  not get replicated before the expiration replication message.
-  That's a problem in case a session listener needs the changed attribute.
-  Patch: http://people.apache.org/~rjung/patches/TC5.5-cluster-replicate-before-expire.patch
-  This has already been applied to OACC: http://svn.apache.org/viewvc?rev=812427&view=rev
-  +1: rjung, pero, markt
-  -1: 
-
 * Port r795052 from modules/ha to modules/cluster
   Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=40551
   Enable the JvmRouteBinderValve to work with PersistentManagers as well as clusters

Modified: tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java
URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java?rev=818061&r1=818060&r2=818061&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java (original)
+++ tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java Wed Sep 23 11:24:22 2009
@@ -1308,6 +1308,25 @@
      * @return a SessionMessage to be sent,
      */
     public ClusterMessage requestCompleted(String sessionId) {
+        return requestCompleted(sessionId, false);
+    }
+
+    /**
+     * When the request has been completed, the replication valve will notify
+     * the manager, and the manager will decide whether any replication is
+     * needed or not. If there is a need for replication, the manager will
+     * create a session message and that will be replicated. The cluster
+     * determines where it gets sent.
+     * 
+     * Session expiration also calls this method, but with expires == true.
+     * 
+     * @param sessionId -
+     *            the sessionId that just completed.
+     * @param expires -
+     *            whether this method has been called during session expiration
+     * @return a SessionMessage to be sent,
+     */
+    public ClusterMessage requestCompleted(String sessionId, boolean expires) {
         try {
             DeltaSession session = (DeltaSession) findSession(sessionId);
             DeltaRequest deltaRequest = session.getDeltaRequest();
@@ -1325,7 +1344,7 @@
                 }  
             }
             if(!isDeltaRequest) {
-                if(!session.isPrimarySession()) {               
+                if(!expires && !session.isPrimarySession()) {
                     counterSend_EVT_SESSION_ACCESSED++;
                     msg = new SessionMessageImpl(getName(),
                             SessionMessage.EVT_SESSION_ACCESSED, null, sessionId,
@@ -1343,9 +1362,10 @@
                         getName(), sessionId));
                 }
             }
-            session.setPrimarySession(true);
+            if (!expires)
+                session.setPrimarySession(true);
             //check to see if we need to send out an access message
-            if ((msg == null)) {
+            if (!expires && (msg == null)) {
                 long replDelta = System.currentTimeMillis()
                         - session.getLastTimeReplicated();
                 if (replDelta >= updateActiveInterval*1000 ||

Modified: tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaSession.java
URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaSession.java?rev=818061&r1=818060&r2=818061&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaSession.java (original)
+++ tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaSession.java Wed Sep 23 11:24:22 2009
@@ -49,7 +49,9 @@
 import org.apache.catalina.Session;
 import org.apache.catalina.SessionEvent;
 import org.apache.catalina.SessionListener;
+import org.apache.catalina.cluster.CatalinaCluster;
 import org.apache.catalina.cluster.ClusterSession;
+import org.apache.catalina.cluster.ClusterMessage;
 import org.apache.catalina.realm.GenericPrincipal;
 import org.apache.catalina.util.Enumerator;
 import org.apache.catalina.util.StringManager;
@@ -717,6 +719,19 @@
 
             expiring = true;
 
+            if(expiredId != null && manager instanceof DeltaManager) {
+                DeltaManager dmanager = (DeltaManager)manager;
+                CatalinaCluster cluster = dmanager.getCluster();
+                ClusterMessage msg = dmanager.requestCompleted(expiredId, true);
+                if (msg != null) {
+                    if(dmanager.isSendClusterDomainOnly()) {
+                        cluster.sendClusterDomain(msg);
+                    } else {
+                        cluster.send(msg);
+                    }
+                }
+            }
+
             // Notify interested application event listeners
             // FIXME - Assumes we call listeners in reverse order
             Context context = (Context) manager.getContainer();

Modified: tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml?rev=818061&r1=818060&r2=818061&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml (original)
+++ tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml Wed Sep 23 11:24:22 2009
@@ -88,6 +88,11 @@
   </subsection>
   <subsection name="Cluster">
     <changelog>
+      <fix>
+        DeltaManager needs to replicate changed attributes even if session
+        gets invalidated. Otherwise session listeners will not see the right
+        data on the secondary nodes. (rjung)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Webapps">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org