Author: markt Date: Fri Mar 6 13:51:53 2009 New Revision: 750895 URL: http://svn.apache.org/viewvc?rev=750895&view=rev Log: Handle session suffix rewrite at JvmRouteBinderValve with parallel requests from same client. Port of pero's change in trunk.
Modified: tomcat/tc6.0.x/trunk/ (props changed) tomcat/tc6.0.x/trunk/STATUS.txt tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/JvmRouteBinderValve.java tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc6.0.x/trunk/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Fri Mar 6 13:51:53 2009 @@ -1 +1 @@ -/tomcat/trunk:601180,606992,612607,630314,652744,653247,673796,673820,683982,684001,684081,684234,684269-684270,685177,687503,687645,689402,690781,691392,691805,692748,694992,695053,695311,696780,696782,698012,698227,698236,698613,699427,699634,701355,709294,709811,709816,710063,710066,710125,710205,711126,711600,712461,712467,718360,719602,719626,719628,720046,720069,721040,723404,723738,726052,727303,728032,728768,728947,729057,729567,729569,729571,729809,729815,729934,730250,730590,731651,732859,732863,734734,740675,740684,747834,748344 +/tomcat/trunk:601180,606992,612607,630314,652744,653247,673796,673820,683982,684001,684081,684234,684269-684270,685177,687503,687645,689402,690781,691392,691805,692748,693378,694992,695053,695311,696780,696782,698012,698227,698236,698613,699427,699634,701355,709294,709811,709816,710063,710066,710125,710205,711126,711600,712461,712467,718360,719602,719626,719628,720046,720069,721040,723404,723738,726052,727303,728032,728768,728947,729057,729567,729569,729571,729809,729815,729934,730250,730590,731651,732859,732863,734734,740675,740684,747834,748344 Modified: tomcat/tc6.0.x/trunk/STATUS.txt URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=750895&r1=750894&r2=750895&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/STATUS.txt (original) +++ tomcat/tc6.0.x/trunk/STATUS.txt Fri Mar 6 13:51:53 2009 @@ -38,11 +38,6 @@ 0: remm (looks risky, very minor problem), fhanik - minor problem -1: -* Handle session suffix rewrite at JvmRouteBinderValve with parallel requests from same client - http://svn.apache.org/viewvc?rev=693378&view=rev - +1: pero, fhanik, markt, jim - -1: - * Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=45026 Never use empty reason phrase. http://svn.apache.org/viewvc?rev=697183&view=rev Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/JvmRouteBinderValve.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/JvmRouteBinderValve.java?rev=750895&r1=750894&r2=750895&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/JvmRouteBinderValve.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/JvmRouteBinderValve.java Fri Mar 6 13:51:53 2009 @@ -35,6 +35,7 @@ import org.apache.catalina.ha.ClusterManager; import org.apache.catalina.ha.ClusterMessage; import org.apache.catalina.ha.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; @@ -217,8 +218,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 = System.currentTimeMillis(); String jvmRoute = getLocalJvmRoute(request); if (jvmRoute == null) { @@ -226,7 +227,7 @@ log.debug(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; @@ -306,23 +307,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)); + } } } } @@ -344,11 +354,36 @@ 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(); - if(request.isRequestedSessionIdFromCookie()) setNewSessionCookie(request, response,newSessionID); + 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 // change if (sessionIdAttribute != null && !"".equals(sessionIdAttribute)) { @@ -357,17 +392,8 @@ } 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)); - } } - + /** * Send the changed Sessionid to all clusternodes. * Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=750895&r1=750894&r2=750895&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Fri Mar 6 13:51:53 2009 @@ -469,6 +469,10 @@ <bug>46357</bug>: Corrected test for host's parent must be an engine. (markt) </fix> + <fix> + Fix so that JvmrouteBinderValve can rewrite session suffix with parallel + requests from same client. (pero) + </fix> </changelog> </subsection> <subsection name="Webapps"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org