The change in session ID is notified to the container event listener.
authorkfujino <kfujino@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 30 Jun 2011 08:39:53 +0000 (08:39 +0000)
committerkfujino <kfujino@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 30 Jun 2011 08:39:53 +0000 (08:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1141441 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/ha/session/DeltaManager.java
java/org/apache/catalina/ha/session/mbeans-descriptors.xml
webapps/docs/changelog.xml
webapps/docs/config/cluster-manager.xml

index e71f9c9..a87b75e 100644 (file)
@@ -97,6 +97,7 @@ public class DeltaManager extends ClusterManagerBase{
     private boolean expireSessionsOnShutdown = false;
     private boolean notifyListenersOnReplication = true;
     private boolean notifySessionListenersOnReplication = true;
+    private boolean notifyContainerListenersOnReplication  = true;
     private volatile boolean stateTransfered = false ;
     private int stateTransferTimeout = 60;
     private boolean sendAllSessions = true;
@@ -420,9 +421,17 @@ public class DeltaManager extends ClusterManagerBase{
         this.notifyListenersOnReplication = notifyListenersOnReplication;
     }
 
+    public boolean isNotifyContainerListenersOnReplication() {
+        return notifyContainerListenersOnReplication;
+    }
+
+    public void setNotifyContainerListenersOnReplication(
+            boolean notifyContainerListenersOnReplication) {
+        this.notifyContainerListenersOnReplication = notifyContainerListenersOnReplication;
+    }
     
-   @Override
-public CatalinaCluster getCluster() {
+    @Override
+    public CatalinaCluster getCluster() {
         return cluster;
     }
 
@@ -1463,7 +1472,11 @@ public CatalinaCluster getCluster() {
         if (session != null) {
             String newSessionID = deserializeSessionId(msg.getSession());
             session.setPrimarySession(false);
-            session.setId(newSessionID, notifySessionListenersOnReplication);
+            session.setId(newSessionID, false);
+            if (notifyContainerListenersOnReplication) {
+                getContainer().fireContainerEvent(Context.CHANGE_SESSION_ID_EVENT,
+                        new String[] {msg.getSessionID(), newSessionID});
+            }
         }
     }
 
@@ -1494,6 +1507,7 @@ public CatalinaCluster getCluster() {
         result.expireSessionsOnShutdown = expireSessionsOnShutdown;
         result.notifyListenersOnReplication = notifyListenersOnReplication;
         result.notifySessionListenersOnReplication = notifySessionListenersOnReplication;
+        result.notifyContainerListenersOnReplication = notifyContainerListenersOnReplication;
         result.stateTransferTimeout = stateTransferTimeout;
         result.sendAllSessions = sendAllSessions;
         result.sendAllSessionsSize = sendAllSessionsSize;
index 154737a..3ece61d 100644 (file)
       description="Send session start/stop events on backup nodes"
       type="boolean"/>
     <attribute
+      name="notifyContainerListenersOnReplication"
+      is="true"
+      description="Send container events on backup nodes"
+      type="boolean"/>
+    <attribute
       name="processExpiresFrequency"
       description="The frequency of the manager checks (expiration and passivation)"
       type="int"/>
index 5f87691..6a0ea14 100644 (file)
         should be controlled by notifySessionListenersOnReplication rather than
         notifyListenersOnReplication. (markt)
       </fix>
+      <fix>
+        The change in session ID is notified to the container event listener on 
+        the backup node in cluster. 
+        This notification is controlled by 
+        notifyContainerListenersOnReplication.(kfujino)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Web applications">
index 233b76d..054c71e 100644 (file)
         when sessions are created and expired across Tomcat nodes in the
         cluster.
       </attribute>
+      <attribute name="notifyContainerListenersOnReplication" required="false">
+        Set to <code>true</code> if you wish to have container listeners notified
+        across Tomcat nodes in the cluster.
+      </attribute>
       <attribute name="stateTransferTimeout" required="false">
         The time in seconds to wait for a session state transfer to complete
         from another node when a node is starting up.