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/12/19 19:09:37 UTC

svn commit: r892491 - in /tomcat/tc5.5.x/trunk: STATUS.txt container/modules/ha/src/share/org/apache/catalina/ha/session/DeltaManager.java container/modules/ha/src/share/org/apache/catalina/ha/session/DeltaSession.java

Author: rjung
Date: Sat Dec 19 18:09:37 2009
New Revision: 892491

URL: http://svn.apache.org/viewvc?rev=892491&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 r818062 (trunk), r812427 (OACC) and r818061 (tc5.5.x, o.a.c.c.)
to o.a.c.ha.

Modified:
    tomcat/tc5.5.x/trunk/STATUS.txt
    tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/DeltaManager.java
    tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/DeltaSession.java

Modified: tomcat/tc5.5.x/trunk/STATUS.txt
URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/STATUS.txt?rev=892491&r1=892490&r2=892491&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/STATUS.txt (original)
+++ tomcat/tc5.5.x/trunk/STATUS.txt Sat Dec 19 18:09:37 2009
@@ -101,16 +101,6 @@
   )
 
 
-* Fix cluster replication problem for o.a.c.ha: 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.
-  Has already been fixed in trunk, OACC and tc5.5.x (only in o.a.c.cluster).
-  http://svn.apache.org/viewvc?rev=818062&view=rev (trunk)
-  +1: rjung, markt, mturk
-  -1:
-
 * Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48097
   There are two patches to be applied:
   1) Make WebappClassLoader to do not swallow AccessControlException

Modified: tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/DeltaManager.java
URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/DeltaManager.java?rev=892491&r1=892490&r2=892491&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/DeltaManager.java (original)
+++ tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/DeltaManager.java Sat Dec 19 18:09:37 2009
@@ -1095,6 +1095,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();
@@ -1114,7 +1133,7 @@
                 }  
             }
             if(!isDeltaRequest) {
-                if(!session.isPrimarySession()) {               
+                if(!expires && !session.isPrimarySession()) {
                     counterSend_EVT_SESSION_ACCESSED++;
                     msg = new SessionMessageImpl(getName(),
                                                  SessionMessage.EVT_SESSION_ACCESSED, 
@@ -1130,9 +1149,10 @@
                     log.debug(sm.getString("deltaManager.createMessage.delta",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 > (getMaxInactiveInterval() * 1000)) {
                     counterSend_EVT_SESSION_ACCESSED++;

Modified: tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/DeltaSession.java
URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/DeltaSession.java?rev=892491&r1=892490&r2=892491&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/DeltaSession.java (original)
+++ tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/DeltaSession.java Sat Dec 19 18:09:37 2009
@@ -34,7 +34,9 @@
 import javax.servlet.http.HttpSessionContext;
 
 import org.apache.catalina.Manager;
+import org.apache.catalina.ha.CatalinaCluster;
 import org.apache.catalina.ha.ClusterManager;
+import org.apache.catalina.ha.ClusterMessage;
 import org.apache.catalina.ha.ClusterSession;
 import org.apache.catalina.realm.GenericPrincipal;
 import org.apache.catalina.session.StandardSession;
@@ -352,7 +354,24 @@
     }
 
     public void expire(boolean notify, boolean notifyCluster) {
+        if (expiring)
+            return;
         String expiredId = getIdInternal();
+
+        if(expiredId != null && manager != 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);
+                }
+            }
+        }
+
         super.expire(notify);
 
         if (notifyCluster) {



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