From 7b67c739cf94e2908a71bd5b16ab0b4de6acf643 Mon Sep 17 00:00:00 2001 From: kfujino Date: Thu, 30 Jun 2011 08:39:53 +0000 Subject: [PATCH] The change in session ID is notified to the container event listener. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1141441 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/catalina/ha/session/DeltaManager.java | 20 +++++++++++++++++--- .../catalina/ha/session/mbeans-descriptors.xml | 5 +++++ webapps/docs/changelog.xml | 6 ++++++ webapps/docs/config/cluster-manager.xml | 4 ++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/java/org/apache/catalina/ha/session/DeltaManager.java b/java/org/apache/catalina/ha/session/DeltaManager.java index e71f9c9d1..a87b75e54 100644 --- a/java/org/apache/catalina/ha/session/DeltaManager.java +++ b/java/org/apache/catalina/ha/session/DeltaManager.java @@ -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; diff --git a/java/org/apache/catalina/ha/session/mbeans-descriptors.xml b/java/org/apache/catalina/ha/session/mbeans-descriptors.xml index 154737a70..3ece61d6b 100644 --- a/java/org/apache/catalina/ha/session/mbeans-descriptors.xml +++ b/java/org/apache/catalina/ha/session/mbeans-descriptors.xml @@ -249,6 +249,11 @@ description="Send session start/stop events on backup nodes" type="boolean"/> + diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 5f87691f1..6a0ea14ea 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -238,6 +238,12 @@ should be controlled by notifySessionListenersOnReplication rather than notifyListenersOnReplication. (markt) + + 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) + diff --git a/webapps/docs/config/cluster-manager.xml b/webapps/docs/config/cluster-manager.xml index 233b76d44..054c71ed8 100644 --- a/webapps/docs/config/cluster-manager.xml +++ b/webapps/docs/config/cluster-manager.xml @@ -105,6 +105,10 @@ when sessions are created and expired across Tomcat nodes in the cluster. + + Set to true if you wish to have container listeners notified + across Tomcat nodes in the cluster. + The time in seconds to wait for a session state transfer to complete from another node when a node is starting up. -- 2.11.0