Author: markt
Date: Tue Apr 28 15:04:48 2009
New Revision: 769428
URL: http://svn.apache.org/viewvc?rev=769428&view=rev
Log:
Backport: Handle session suffix rewrite at JvmRouteBinderValve with parallel
requests from same client (pero)
Modified:
tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java
(contents, props changed)
tomcat/container/tc5.5.x/webapps/docs/changelog.xml
Modified:
tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java
URL:
http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java?rev=769428&r1=769427&r2=769428&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java
(original)
+++
tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java
Tue Apr 28 15:04:48 2009
@@ -35,6 +35,7 @@
import org.apache.catalina.cluster.ClusterManager;
import org.apache.catalina.cluster.ClusterMessage;
import org.apache.catalina.cluster.ClusterValve;
+import org.apache.catalina.ha.session.DeltaSession;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.session.ManagerBase;
@@ -218,8 +219,8 @@
* @param response current response
*/
protected void handlePossibleTurnover(Request request, Response response) {
- Session session = request.getSessionInternal(false);
- if (session != null) {
+ String sessionID = request.getRequestedSessionId() ;
+ if (sessionID != null) {
long t1 = 0 ;
if (log.isDebugEnabled()) {
t1 = System.currentTimeMillis();
@@ -230,7 +231,7 @@
log.warn(sm.getString("jvmRoute.missingJvmRouteAttribute"));
return;
}
- handleJvmRoute( request, response,session.getIdInternal(),
jvmRoute);
+ handleJvmRoute( request, response, sessionID, jvmRoute);
if (log.isDebugEnabled()) {
long t2 = System.currentTimeMillis();
long time = t2 - t1;
@@ -310,23 +311,32 @@
log.debug(sm.getString("jvmRoute.failover", requestJvmRoute,
localJvmRoute, sessionId));
}
- // OK - turnover the session ?
- String newSessionID = sessionId.substring(0, index) + "."
- + localJvmRoute;
Session catalinaSession = null;
try {
catalinaSession = getManager(request).findSession(sessionId);
} catch (IOException e) {
// Hups!
}
+ String id = sessionId.substring(0, index);
+ String newSessionID = id + "." + localJvmRoute;
+ // OK - turnover the session and inform other cluster nodes
if (catalinaSession != null) {
changeSessionID(request, response, sessionId, newSessionID,
catalinaSession);
numberOfSessions++;
} else {
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("jvmRoute.cannotFindSession",
- sessionId));
+ try {
+ catalinaSession =
getManager(request).findSession(newSessionID);
+ } catch (IOException e) {
+ // Hups!
+ }
+ if (catalinaSession != null) {
+ // session is rewrite at other request, rewrite this also
+ changeRequestSessionID(request, response, sessionId,
newSessionID);
+ } else {
+ if (log.isDebugEnabled()) {
+
log.debug(sm.getString("jvmRoute.cannotFindSession",sessionId));
+ }
}
}
}
@@ -348,10 +358,34 @@
Response response, String sessionId, String newSessionID, Session
catalinaSession) {
lifecycle.fireLifecycleEvent("Before session migration",
catalinaSession);
- request.setRequestedSessionId(newSessionID);
+ // FIXME: setId trigger session Listener, but only chance to
registiert manager with correct id!
catalinaSession.setId(newSessionID);
+ // FIXME: Why we remove change data from other running request?
+ // setId also trigger resetDeltaRequest!!
if (catalinaSession instanceof DeltaSession)
((DeltaSession) catalinaSession).resetDeltaRequest();
+ changeRequestSessionID(request, response, sessionId, newSessionID);
+ // now sending the change to all other clusternode!
+ ClusterManager manager = (ClusterManager)catalinaSession.getManager();
+ sendSessionIDClusterBackup(manager,request,sessionId, newSessionID);
+ lifecycle.fireLifecycleEvent("After session migration",
catalinaSession);
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("jvmRoute.changeSession", sessionId,
+ newSessionID));
+ }
+ }
+
+ /**
+ * Change Request Session id
+ * @param request current request
+ * @param response current response
+ * @param sessionId
+ * original session id
+ * @param newSessionID
+ * new session id for node migration
+ */
+ protected void changeRequestSessionID(Request request, Response response,
String sessionId, String newSessionID) {
+ request.setRequestedSessionId(newSessionID);
if(request.isRequestedSessionIdFromCookie())
setNewSessionCookie(request, response,newSessionID);
// set orginal sessionid at request, to allow application detect the
@@ -362,15 +396,6 @@
}
request.setAttribute(sessionIdAttribute, sessionId);
}
- // now sending the change to all other clusternode!
- ClusterManager manager = (ClusterManager)catalinaSession.getManager();
- sendSessionIDClusterBackup(manager,request,sessionId, newSessionID);
- lifecycle
- .fireLifecycleEvent("After session migration",
catalinaSession);
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("jvmRoute.changeSession", sessionId,
- newSessionID));
- }
}
/**
Propchange:
tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Apr 28 15:04:48 2009
@@ -0,0 +1 @@
+/tomcat/trunk/java/org/apache/catalina/ha/session/JvmRouteBinderValve.java:693378
Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?rev=769428&r1=769427&r2=769428&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Tue Apr 28 15:04:48 2009
@@ -77,6 +77,14 @@
</fix>
</changelog>
</subsection>
+ <subsection name="Cluster">
+ <changelog>
+ <fix>
+ Handle situation session ID rewriting on fail-over with parallel
requests
+ from the same client. (pero)
+ </fix>
+ </changelog>
+ </subsection>
<subsection name="Webapps">
<changelog>
<fix>
@@ -193,7 +201,7 @@
</fix>
</changelog>
</subsection>
- <subsection name="Connectors">
+ <subsection name="Coyote">
<changelog>
<update>
Log errors for AJP signoffs at DEBUG level, since it is harmless if
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]