You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kf...@apache.org on 2010/06/28 09:41:59 UTC
svn commit: r958491 - in /tomcat/tc5.5.x/trunk: ./
container/modules/cluster/src/share/org/apache/catalina/cluster/session/
container/modules/ha/src/share/org/apache/catalina/ha/session/
container/webapps/docs/
Author: kfujino
Date: Mon Jun 28 07:41:58 2010
New Revision: 958491
URL: http://svn.apache.org/viewvc?rev=958491&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49445
The change in session ID is notified to other node.
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/LocalStrings.properties
tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/SessionMessage.java
tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/SessionMessageImpl.java
tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/mbeans-descriptors.xml
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/LocalStrings.properties
tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/SessionMessage.java
tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/SessionMessageImpl.java
tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/mbeans-descriptors.xml
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=958491&r1=958490&r2=958491&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/STATUS.txt (original)
+++ tomcat/tc5.5.x/trunk/STATUS.txt Mon Jun 28 07:41:58 2010
@@ -54,11 +54,3 @@ PATCHES PROPOSED TO BACKPORT:
http://svn.apache.org/viewvc?view=revision&revision=749019
-1:
-* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49445
- The change in session ID is notified to other node.
- http://svn.apache.org/viewvc?view=revision&revision=955190
- +1: kfujino, markt
- +1: kkolinko:
- 1. to apply to both o.a.c.cluster.session.* and o.a.c.ha.session.*
- 2. do not forget to omit the @Override annotation
- -1:
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=958491&r1=958490&r2=958491&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 Mon Jun 28 07:41:58 2010
@@ -173,8 +173,6 @@ public class DeltaManager extends Manage
private long counterReceive_EVT_GET_ALL_SESSIONS = 0 ;
- private long counterSend_EVT_ALL_SESSION_DATA = 0 ;
-
private long counterReceive_EVT_ALL_SESSION_DATA = 0 ;
private long counterReceive_EVT_SESSION_CREATED = 0 ;
@@ -185,8 +183,14 @@ public class DeltaManager extends Manage
private long counterReceive_EVT_SESSION_DELTA = 0;
+ private int counterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE = 0 ;
+
+ private long counterReceive_EVT_CHANGE_SESSION_ID = 0 ;
+
private long counterSend_EVT_GET_ALL_SESSIONS = 0 ;
+ private long counterSend_EVT_ALL_SESSION_DATA = 0 ;
+
private long counterSend_EVT_SESSION_CREATED = 0;
private long counterSend_EVT_SESSION_DELTA = 0 ;
@@ -197,7 +201,7 @@ public class DeltaManager extends Manage
private int counterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE = 0 ;
- private int counterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE = 0 ;
+ private long counterSend_EVT_CHANGE_SESSION_ID = 0;
private int counterNoStateTransfered = 0 ;
@@ -312,7 +316,14 @@ public class DeltaManager extends Manage
public int getCounterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE() {
return counterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE;
}
-
+
+ /**
+ * @return Returns the counterSend_EVT_CHANGE_SESSION_ID.
+ */
+ public long getCounterSend_EVT_CHANGE_SESSION_ID() {
+ return counterSend_EVT_CHANGE_SESSION_ID;
+ }
+
/**
* @return Returns the counterReceive_EVT_ALL_SESSION_DATA.
*/
@@ -362,7 +373,14 @@ public class DeltaManager extends Manage
public int getCounterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE() {
return counterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE;
}
-
+
+ /**
+ * @return Returns the counterReceive_EVT_CHANGE_SESSION_ID.
+ */
+ public long getCounterReceive_EVT_CHANGE_SESSION_ID() {
+ return counterReceive_EVT_CHANGE_SESSION_ID;
+ }
+
/**
* @return Returns the processingTime.
*/
@@ -707,6 +725,67 @@ public class DeltaManager extends Manage
}
/**
+ * Change the session ID of the current session to a new randomly generated
+ * session ID.
+ *
+ * @param session The session to change the session ID for
+ */
+ public void changeSessionId(Session session) {
+ changeSessionId(session, true);
+ }
+
+ public void changeSessionId(Session session, boolean notify) {
+ // original sessionID
+ String orgSessionID = session.getId();
+ super.changeSessionId(session);
+ if (notify) {
+ // changed sessionID
+ String newSessionID = session.getId();
+ try {
+ // serialize sessionID
+ byte[] data = serializeSessionId(newSessionID);
+ // notify change sessionID
+ SessionMessage msg = new SessionMessageImpl(getName(),
+ SessionMessage.EVT_CHANGE_SESSION_ID, data,
+ orgSessionID, orgSessionID + "-"
+ + System.currentTimeMillis());
+ counterSend_EVT_CHANGE_SESSION_ID++;
+ send(msg);
+ } catch (IOException e) {
+ log.error(sm.getString("deltaManager.unableSerializeSessionID",
+ newSessionID), e);
+ }
+ }
+ }
+
+ /**
+ * serialize sessionID
+ * @throws IOException if an input/output error occurs
+ */
+ protected byte[] serializeSessionId(String sessionId) throws IOException {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(bos);
+ oos.writeUTF(sessionId);
+ oos.flush();
+ oos.close();
+ return bos.toByteArray();
+ }
+
+ /**
+ * Load sessionID
+ * @throws IOException if an input/output error occurs
+ */
+ protected String deserializeSessionId(byte[] data) throws IOException {
+ ByteArrayInputStream fis = null;
+ ReplicationStream ois = null;
+ fis = new ByteArrayInputStream(data);
+ ois = new ReplicationStream(fis, getClassLoaders(this.container)[0]);
+ String sessionId = ois.readUTF();
+ ois.close();
+ return sessionId;
+ }
+
+ /**
* Load Deltarequest from external node
* Load the Class at container classloader
* @see DeltaRequest#readExternal(java.io.ObjectInput)
@@ -1279,7 +1358,8 @@ public class DeltaManager extends Manage
case SessionMessage.EVT_SESSION_CREATED:
case SessionMessage.EVT_SESSION_EXPIRED:
case SessionMessage.EVT_SESSION_ACCESSED:
- case SessionMessage.EVT_SESSION_DELTA: {
+ case SessionMessage.EVT_SESSION_DELTA:
+ case SessionMessage.EVT_CHANGE_SESSION_ID: {
synchronized(receivedMessageQueue) {
if(receiverQueue) {
receivedMessageQueue.add(msg);
@@ -1417,6 +1497,7 @@ public class DeltaManager extends Manage
counterReceive_EVT_SESSION_DELTA = 0 ;
counterReceive_EVT_SESSION_EXPIRED = 0 ;
counterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE = 0;
+ counterReceive_EVT_CHANGE_SESSION_ID = 0;
counterSend_EVT_ALL_SESSION_DATA = 0;
counterSend_EVT_GET_ALL_SESSIONS = 0;
counterSend_EVT_SESSION_ACCESSED = 0 ;
@@ -1424,6 +1505,7 @@ public class DeltaManager extends Manage
counterSend_EVT_SESSION_DELTA = 0 ;
counterSend_EVT_SESSION_EXPIRED = 0 ;
counterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE = 0;
+ counterSend_EVT_CHANGE_SESSION_ID = 0;
}
@@ -1573,6 +1655,10 @@ public class DeltaManager extends Manage
handleSESSION_DELTA(msg,sender);
break;
}
+ case SessionMessage.EVT_CHANGE_SESSION_ID: {
+ handleCHANGE_SESSION_ID(msg,sender);
+ break;
+ }
default: {
//we didn't recognize the message type, do nothing
break;
@@ -1771,6 +1857,24 @@ public class DeltaManager extends Manage
cluster.send(newmsg, sender);
}
+ /**
+ * handle receive change sessionID at other node
+ * @param msg
+ * @param sender
+ * @throws IOException
+ */
+ protected void handleCHANGE_SESSION_ID(SessionMessage msg,Member sender) throws IOException {
+ counterReceive_EVT_CHANGE_SESSION_ID++;
+ DeltaSession session = (DeltaSession) findSession(msg.getSessionID());
+ String newSessionID = deserializeSessionId(msg.getSession());
+ session.setPrimarySession(false);
+ if(notifySessionListenersOnReplication) {
+ session.setId(newSessionID);
+ } else {
+ session.setIdInternal(newSessionID);
+ add(session);
+ }
+ }
/**
* send a block of session to sender
Modified: tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/LocalStrings.properties?rev=958491&r1=958490&r2=958491&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/LocalStrings.properties (original)
+++ tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/LocalStrings.properties Mon Jun 28 07:41:58 2010
@@ -56,6 +56,7 @@ deltaManager.startClustering=Starting cl
deltaManager.stopped=Manager [{0}] is stopping
deltaManager.unloading.ioe=IOException while saving persisted sessions: {0}
deltaManager.waitForSessionState=Manager [{0}], requesting session state from {1}. This operation will timeout if no session state has been received within {2} seconds.
+deltaManager.unableSerializeSessionID =Unable to serialize sessionID [{0}]
deltaRequest.showPrincipal=Principal [{0}] is set to session {1}
deltaRequest.wrongPrincipalClass=DeltaManager only support GenericPrincipal. Your realm used principal class {0}.
deltaSession.notifying=Notifying cluster of expiration primary={0} sessionId [{1}]
Modified: tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/SessionMessage.java
URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/SessionMessage.java?rev=958491&r1=958490&r2=958491&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/SessionMessage.java (original)
+++ tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/SessionMessage.java Mon Jun 28 07:41:58 2010
@@ -26,15 +26,13 @@ import org.apache.catalina.cluster.Clust
* The following events are currently available:
* <ul>
* <li><pre>public static final int EVT_SESSION_CREATED</pre><li>
+ * <li><pre>public static final int EVT_SESSION_EXPIRED</pre><li>
* <li><pre>public static final int EVT_SESSION_ACCESSED</pre><li>
- * <li><pre>public static final int EVT_ATTRIBUTE_ADDED</pre><li>
- * <li><pre>public static final int EVT_ATTRIBUTE_REMOVED</pre><li>
- * <li><pre>public static final int EVT_SESSION_EXPIRED_WONOTIFY</pre><li>
- * <li><pre>public static final int EVT_SESSION_EXPIRED_WNOTIFY</pre><li>
* <li><pre>public static final int EVT_GET_ALL_SESSIONS</pre><li>
- * <li><pre>public static final int EVT_SET_USER_PRINCIPAL</pre><li>
- * <li><pre>public static final int EVT_SET_SESSION_NOTE</pre><li>
- * <li><pre>public static final int EVT_REMOVE_SESSION_NOTE</pre><li>
+ * <li><pre>public static final int EVT_SESSION_DELTA</pre><li>
+ * <li><pre>public static final int EVT_ALL_SESSION_DATA</pre><li>
+ * <li><pre>public static final int EVT_ALL_SESSION_TRANSFERCOMPLETE</pre><li>
+ * <li><pre>public static final int EVT_CHANGE_SESSION_ID</pre><li>
* </ul>
*
*/
@@ -78,9 +76,13 @@ public interface SessionMessage extends
* When a session state is complete transferred, this is the event.
*/
public static final int EVT_ALL_SESSION_TRANSFERCOMPLETE = 14;
-
-
+ /**
+ * Event type used when a sessionID has been changed.
+ */
+ public static final int EVT_CHANGE_SESSION_ID = 15;
+
+
public String getContextName();
public String getEventTypeString();
Modified: tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/SessionMessageImpl.java
URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/SessionMessageImpl.java?rev=958491&r1=958490&r2=958491&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/SessionMessageImpl.java (original)
+++ tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/SessionMessageImpl.java Mon Jun 28 07:41:58 2010
@@ -72,8 +72,8 @@ public class SessionMessageImpl implemen
* The parameters: sessionID must be set.<BR>
* <B>EVT_SESSION_ACCESSED</B><BR>
* The parameters: sessionID must be set.<BR>
- * <B>EVT_SESSION_EXPIRED_XXXX</B><BR>
- * The parameters: sessionID must be set.<BR>
+ * <B>EVT_GET_ALL_SESSIONS</B><BR>
+ * get all sessions from from one of the nodes.<BR>
* <B>EVT_SESSION_DELTA</B><BR>
* Send attribute delta (add,update,remove attribute or principal, ...).<BR>
* <B>EVT_ALL_SESSION_DATA</B><BR>
@@ -81,6 +81,8 @@ public class SessionMessageImpl implemen
* <B>EVT_ALL_SESSION_TRANSFERCOMPLETE</B><BR>
* send that all session state information are transfered
* after GET_ALL_SESSION received from this sender.<BR>
+ * <B>EVT_CHANGE_SESSION_ID</B><BR>
+ * send original sessionID and new sessionID.<BR>
* @param contextName - the name of the context (application
* @param eventtype - one of the 8 event type defined in this class
* @param session - the serialized byte array of the session itself
@@ -142,6 +144,7 @@ public class SessionMessageImpl implemen
case EVT_SESSION_DELTA : return "SESSION-DELTA";
case EVT_ALL_SESSION_DATA : return "ALL-SESSION-DATA";
case EVT_ALL_SESSION_TRANSFERCOMPLETE : return "SESSION-STATE-TRANSFERED";
+ case EVT_CHANGE_SESSION_ID : return "SESSION-ID-CHANGED";
default : return "UNKNOWN-EVENT-TYPE";
}
}
Modified: tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/mbeans-descriptors.xml
URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/mbeans-descriptors.xml?rev=958491&r1=958490&r2=958491&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/mbeans-descriptors.xml (original)
+++ tomcat/tc5.5.x/trunk/container/modules/cluster/src/share/org/apache/catalina/cluster/session/mbeans-descriptors.xml Mon Jun 28 07:41:58 2010
@@ -243,6 +243,11 @@
type="long"
writeable="false" />
+ <attribute name="counterReceive_EVT_CHANGE_SESSION_ID"
+ description="Count receive EVT_CHANGE_SESSION_ID messages"
+ type="long"
+ writeable="false"/>
+
<attribute name="counterSend_EVT_GET_ALL_SESSIONS"
description="Count send EVT_GET_ALL_SESSIONS messages"
type="long"
@@ -278,6 +283,11 @@
type="long"
writeable="false" />
+ <attribute name="counterSend_EVT_CHANGE_SESSION_ID"
+ description="Count send EVT_CHANGE_SESSION_ID messages"
+ type="long"
+ writeable="false"/>
+
<attribute name="counterNoStateTransfered"
description="Count the failed session transfers noStateTransfered"
type="int"
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=958491&r1=958490&r2=958491&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 Mon Jun 28 07:41:58 2010
@@ -132,19 +132,21 @@ public class DeltaManager extends Cluste
private long sessionReplaceCounter = 0 ;
long processingTime = 0;
private long counterReceive_EVT_GET_ALL_SESSIONS = 0 ;
- private long counterSend_EVT_ALL_SESSION_DATA = 0 ;
private long counterReceive_EVT_ALL_SESSION_DATA = 0 ;
private long counterReceive_EVT_SESSION_CREATED = 0 ;
private long counterReceive_EVT_SESSION_EXPIRED = 0;
private long counterReceive_EVT_SESSION_ACCESSED = 0 ;
private long counterReceive_EVT_SESSION_DELTA = 0;
+ private int counterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE = 0 ;
+ private long counterReceive_EVT_CHANGE_SESSION_ID = 0 ;
private long counterSend_EVT_GET_ALL_SESSIONS = 0 ;
+ private long counterSend_EVT_ALL_SESSION_DATA = 0 ;
private long counterSend_EVT_SESSION_CREATED = 0;
private long counterSend_EVT_SESSION_DELTA = 0 ;
private long counterSend_EVT_SESSION_ACCESSED = 0;
private long counterSend_EVT_SESSION_EXPIRED = 0;
private int counterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE = 0 ;
- private int counterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE = 0 ;
+ private long counterSend_EVT_CHANGE_SESSION_ID = 0;
private int counterNoStateTransfered = 0 ;
@@ -225,6 +227,13 @@ public class DeltaManager extends Cluste
}
/**
+ * @return Returns the counterSend_EVT_CHANGE_SESSION_ID.
+ */
+ public long getCounterSend_EVT_CHANGE_SESSION_ID() {
+ return counterSend_EVT_CHANGE_SESSION_ID;
+ }
+
+ /**
* @return Returns the counterReceive_EVT_ALL_SESSION_DATA.
*/
public long getCounterReceive_EVT_ALL_SESSION_DATA() {
@@ -273,7 +282,14 @@ public class DeltaManager extends Cluste
public int getCounterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE() {
return counterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE;
}
-
+
+ /**
+ * @return Returns the counterReceive_EVT_CHANGE_SESSION_ID.
+ */
+ public long getCounterReceive_EVT_CHANGE_SESSION_ID() {
+ return counterReceive_EVT_CHANGE_SESSION_ID;
+ }
+
/**
* @return Returns the processingTime.
*/
@@ -604,6 +620,64 @@ public class DeltaManager extends Cluste
}
/**
+ * Change the session ID of the current session to a new randomly generated
+ * session ID.
+ *
+ * @param session The session to change the session ID for
+ */
+ public void changeSessionId(Session session) {
+ changeSessionId(session, true);
+ }
+
+ public void changeSessionId(Session session, boolean notify) {
+ // original sessionID
+ String orgSessionID = session.getId();
+ super.changeSessionId(session);
+ if (notify) {
+ // changed sessionID
+ String newSessionID = session.getId();
+ try {
+ // serialize sessionID
+ byte[] data = serializeSessionId(newSessionID);
+ // notify change sessionID
+ SessionMessage msg = new SessionMessageImpl(getName(),
+ SessionMessage.EVT_CHANGE_SESSION_ID, data,
+ orgSessionID, orgSessionID + "-"
+ + System.currentTimeMillis());
+ counterSend_EVT_CHANGE_SESSION_ID++;
+ send(msg);
+ } catch (IOException e) {
+ log.error(sm.getString("deltaManager.unableSerializeSessionID",
+ newSessionID), e);
+ }
+ }
+ }
+
+ /**
+ * serialize sessionID
+ * @throws IOException if an input/output error occurs
+ */
+ protected byte[] serializeSessionId(String sessionId) throws IOException {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(bos);
+ oos.writeUTF(sessionId);
+ oos.flush();
+ oos.close();
+ return bos.toByteArray();
+ }
+
+ /**
+ * Load sessionID
+ * @throws IOException if an input/output error occurs
+ */
+ protected String deserializeSessionId(byte[] data) throws IOException {
+ ReplicationStream ois = getReplicationStream(data);
+ String sessionId = ois.readUTF();
+ ois.close();
+ return sessionId;
+ }
+
+ /**
* Load Deltarequest from external node
* Load the Class at container classloader
* @see DeltaRequest#readExternal(java.io.ObjectInput)
@@ -1067,7 +1141,8 @@ public class DeltaManager extends Cluste
case SessionMessage.EVT_SESSION_CREATED:
case SessionMessage.EVT_SESSION_EXPIRED:
case SessionMessage.EVT_SESSION_ACCESSED:
- case SessionMessage.EVT_SESSION_DELTA: {
+ case SessionMessage.EVT_SESSION_DELTA:
+ case SessionMessage.EVT_CHANGE_SESSION_ID: {
synchronized(receivedMessageQueue) {
if(receiverQueue) {
receivedMessageQueue.add(msg);
@@ -1198,6 +1273,7 @@ public class DeltaManager extends Cluste
counterReceive_EVT_SESSION_DELTA = 0 ;
counterReceive_EVT_SESSION_EXPIRED = 0 ;
counterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE = 0;
+ counterReceive_EVT_CHANGE_SESSION_ID = 0;
counterSend_EVT_ALL_SESSION_DATA = 0;
counterSend_EVT_GET_ALL_SESSIONS = 0;
counterSend_EVT_SESSION_ACCESSED = 0 ;
@@ -1205,6 +1281,7 @@ public class DeltaManager extends Cluste
counterSend_EVT_SESSION_DELTA = 0 ;
counterSend_EVT_SESSION_EXPIRED = 0 ;
counterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE = 0;
+ counterSend_EVT_CHANGE_SESSION_ID = 0;
}
@@ -1342,6 +1419,10 @@ public class DeltaManager extends Cluste
handleSESSION_DELTA(msg,sender);
break;
}
+ case SessionMessage.EVT_CHANGE_SESSION_ID: {
+ handleCHANGE_SESSION_ID(msg,sender);
+ break;
+ }
default: {
//we didn't recognize the message type, do nothing
break;
@@ -1501,6 +1582,24 @@ public class DeltaManager extends Cluste
cluster.send(newmsg, sender);
}
+ /**
+ * handle receive change sessionID at other node
+ * @param msg
+ * @param sender
+ * @throws IOException
+ */
+ protected void handleCHANGE_SESSION_ID(SessionMessage msg,Member sender) throws IOException {
+ counterReceive_EVT_CHANGE_SESSION_ID++;
+ DeltaSession session = (DeltaSession) findSession(msg.getSessionID());
+ String newSessionID = deserializeSessionId(msg.getSession());
+ session.setPrimarySession(false);
+ if(notifySessionListenersOnReplication) {
+ session.setId(newSessionID);
+ } else {
+ session.setIdInternal(newSessionID);
+ add(session);
+ }
+ }
/**
* send a block of session to sender
Modified: tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/LocalStrings.properties?rev=958491&r1=958490&r2=958491&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/LocalStrings.properties (original)
+++ tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/LocalStrings.properties Mon Jun 28 07:41:58 2010
@@ -56,6 +56,7 @@ deltaManager.startClustering=Starting cl
deltaManager.stopped=Manager [{0}] is stopping
deltaManager.unloading.ioe=IOException while saving persisted sessions: {0}
deltaManager.waitForSessionState=Manager [{0}], requesting session state from {1}. This operation will timeout if no session state has been received within 60 seconds.
+deltaManager.unableSerializeSessionID =Unable to serialize sessionID [{0}]
deltaRequest.showPrincipal=Principal [{0}] is set to session {1}
deltaRequest.wrongPrincipalClass=DeltaManager only support GenericPrincipal. Your realm used principal class {0}.
deltaSession.notifying=Notifying cluster of expiration primary={0} sessionId [{1}]
Modified: tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/SessionMessage.java
URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/SessionMessage.java?rev=958491&r1=958490&r2=958491&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/SessionMessage.java (original)
+++ tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/SessionMessage.java Mon Jun 28 07:41:58 2010
@@ -26,15 +26,13 @@ import org.apache.catalina.ha.ClusterMes
* The following events are currently available:
* <ul>
* <li><pre>public static final int EVT_SESSION_CREATED</pre><li>
+ * <li><pre>public static final int EVT_SESSION_EXPIRED</pre><li>
* <li><pre>public static final int EVT_SESSION_ACCESSED</pre><li>
- * <li><pre>public static final int EVT_ATTRIBUTE_ADDED</pre><li>
- * <li><pre>public static final int EVT_ATTRIBUTE_REMOVED</pre><li>
- * <li><pre>public static final int EVT_SESSION_EXPIRED_WONOTIFY</pre><li>
- * <li><pre>public static final int EVT_SESSION_EXPIRED_WNOTIFY</pre><li>
* <li><pre>public static final int EVT_GET_ALL_SESSIONS</pre><li>
- * <li><pre>public static final int EVT_SET_USER_PRINCIPAL</pre><li>
- * <li><pre>public static final int EVT_SET_SESSION_NOTE</pre><li>
- * <li><pre>public static final int EVT_REMOVE_SESSION_NOTE</pre><li>
+ * <li><pre>public static final int EVT_SESSION_DELTA</pre><li>
+ * <li><pre>public static final int EVT_ALL_SESSION_DATA</pre><li>
+ * <li><pre>public static final int EVT_ALL_SESSION_TRANSFERCOMPLETE</pre><li>
+ * <li><pre>public static final int EVT_CHANGE_SESSION_ID</pre><li>
* </ul>
*
*/
@@ -79,8 +77,12 @@ public interface SessionMessage extends
*/
public static final int EVT_ALL_SESSION_TRANSFERCOMPLETE = 14;
+ /**
+ * Event type used when a sessionID has been changed.
+ */
+ public static final int EVT_CHANGE_SESSION_ID = 15;
+
-
public String getContextName();
public String getEventTypeString();
Modified: tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/SessionMessageImpl.java
URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/SessionMessageImpl.java?rev=958491&r1=958490&r2=958491&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/SessionMessageImpl.java (original)
+++ tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/SessionMessageImpl.java Mon Jun 28 07:41:58 2010
@@ -17,8 +17,6 @@
package org.apache.catalina.ha.session;
-import org.apache.catalina.ha.ClusterMessage;
-import org.apache.catalina.tribes.Member;
import org.apache.catalina.ha.ClusterMessageBase;
/**
@@ -71,8 +69,8 @@ public class SessionMessageImpl extends
* The parameters: sessionID must be set.<BR>
* <B>EVT_SESSION_ACCESSED</B><BR>
* The parameters: sessionID must be set.<BR>
- * <B>EVT_SESSION_EXPIRED_XXXX</B><BR>
- * The parameters: sessionID must be set.<BR>
+ * <B>EVT_GET_ALL_SESSIONS</B><BR>
+ * get all sessions from from one of the nodes.<BR>
* <B>EVT_SESSION_DELTA</B><BR>
* Send attribute delta (add,update,remove attribute or principal, ...).<BR>
* <B>EVT_ALL_SESSION_DATA</B><BR>
@@ -80,6 +78,8 @@ public class SessionMessageImpl extends
* <B>EVT_ALL_SESSION_TRANSFERCOMPLETE</B><BR>
* send that all session state information are transfered
* after GET_ALL_SESSION received from this sender.<BR>
+ * <B>EVT_CHANGE_SESSION_ID</B><BR>
+ * send original sessionID and new sessionID.<BR>
* @param contextName - the name of the context (application
* @param eventtype - one of the 8 event type defined in this class
* @param session - the serialized byte array of the session itself
@@ -141,6 +141,7 @@ public class SessionMessageImpl extends
case EVT_SESSION_DELTA : return "SESSION-DELTA";
case EVT_ALL_SESSION_DATA : return "ALL-SESSION-DATA";
case EVT_ALL_SESSION_TRANSFERCOMPLETE : return "SESSION-STATE-TRANSFERED";
+ case EVT_CHANGE_SESSION_ID : return "SESSION-ID-CHANGED";
default : return "UNKNOWN-EVENT-TYPE";
}
}
Modified: tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/mbeans-descriptors.xml
URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/mbeans-descriptors.xml?rev=958491&r1=958490&r2=958491&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/mbeans-descriptors.xml (original)
+++ tomcat/tc5.5.x/trunk/container/modules/ha/src/share/org/apache/catalina/ha/session/mbeans-descriptors.xml Mon Jun 28 07:41:58 2010
@@ -199,6 +199,11 @@
type="long"
writeable="false" />
+ <attribute name="counterReceive_EVT_CHANGE_SESSION_ID"
+ description="Count receive EVT_CHANGE_SESSION_ID messages"
+ type="long"
+ writeable="false"/>
+
<attribute name="counterSend_EVT_GET_ALL_SESSIONS"
description="Count send EVT_GET_ALL_SESSIONS messages"
type="long"
@@ -234,6 +239,11 @@
type="long"
writeable="false" />
+ <attribute name="counterSend_EVT_CHANGE_SESSION_ID"
+ description="Count send EVT_CHANGE_SESSION_ID messages"
+ type="long"
+ writeable="false"/>
+
<attribute name="counterNoStateTransfered"
description="Count the failed session transfers noStateTransfered"
type="int"
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=958491&r1=958490&r2=958491&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml (original)
+++ tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml Mon Jun 28 07:41:58 2010
@@ -158,6 +158,11 @@
<fix>
<bug>49170</bug>: Do not send duplicated session. (kfujino)
</fix>
+ <fix>
+ <bug>49445</bug>: When session ID is changed after authentication,
+ ensure the DeltaManager replicates the change in ID to the other nodes
+ in the cluster. (kfujino)
+ </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