[jboss-cvs] JBossAS SVN: r57245 - in branches/JBoss_4_0_3_SP1_CP: testsuite testsuite/imports testsuite/src/main/org/jboss/test/cluster/test testsuite/src/main/org/jboss/test/cluster/web testsuite/src/main/org/jboss/test/cluster/web/jk testsuite/src/main/org/jboss/test/cluster/web/jk/test testsuite/src/resources/cluster/http testsuite/src/resources/cluster/http/http-jk testsuite/src/resources/cluster/http/http-jk/WEB-INF tomcat/src/main/org/jboss/web/tomcat/tc5/session
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Sep 27 18:14:27 EDT 2006
Author: ryan.campbell at jboss.com
Date: 2006-09-27 18:14:25 -0400 (Wed, 27 Sep 2006)
New Revision: 57245
Added:
branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/cluster/web/jk/
branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/cluster/web/jk/test/
branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/cluster/web/jk/test/JvmRouteURLRewritingTestCase.java
branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/
branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/WEB-INF/
branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/WEB-INF/context.xml
branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/WEB-INF/jboss-web.xml
branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/WEB-INF/web.xml
branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/accessSession.jsp
Removed:
branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/cluster/web/jk/test/
branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/cluster/web/jk/test/JvmRouteURLRewritingTestCase.java
branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/WEB-INF/
branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/WEB-INF/context.xml
branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/WEB-INF/jboss-web.xml
branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/WEB-INF/web.xml
branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/accessSession.jsp
Modified:
branches/JBoss_4_0_3_SP1_CP/testsuite/build.xml
branches/JBoss_4_0_3_SP1_CP/testsuite/imports/test-jars.xml
branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/cluster/test/BaseTest.java
branches/JBoss_4_0_3_SP1_CP/tomcat/src/main/org/jboss/web/tomcat/tc5/session/JvmRouteValve.java
Log:
merged ASPATCH-19: JBAS-3037: Port fix for JBAS-3015 to 4.0.3.SP1: Adds support for modifying the jvmRoute portion of a session id
Modified: branches/JBoss_4_0_3_SP1_CP/testsuite/build.xml
===================================================================
--- branches/JBoss_4_0_3_SP1_CP/testsuite/build.xml 2006-09-27 21:30:18 UTC (rev 57244)
+++ branches/JBoss_4_0_3_SP1_CP/testsuite/build.xml 2006-09-27 22:14:25 UTC (rev 57245)
@@ -490,7 +490,9 @@
</patternset>
<patternset id="cluster.excludes">
<exclude name="org/jboss/test/cluster/test/*TestCase.class"/>
+ <exclude name="org/jboss/test/cluster/web/jk/test/*TestCase.class"/>
<exclude name="org/jboss/test/testbeancluster/test/*TestCase.class"/>
+ <exclude name="org/jboss/test/ha/farm/test/*TestCase.class" />
</patternset>
<patternset id="apache_tomcat.cluster.includes">
<include name="org/jboss/test/cluster/apache_tomcat/*TestCase.class"/>
@@ -826,7 +828,6 @@
<server:start name="node0"/>
<server:start name="node1"/>
- <!-- Need a custom condition that queries for the node membership == 2 -->
<echo message="Going to call target tests-clustering-unit"/>
<antcall target="tests-clustering-unit">
@@ -850,6 +851,16 @@
<param name="cluster.includes.refid" value="cluster.includes"/>
<param name="jboss-junit-configuration" value="SyncModeNUseJvm-${jboss-junit-configuration}"/>
</antcall>
+
+ <patternset id="cluster.jk.includes">
+ <include name="org/jboss/test/cluster/web/jk/test/*TestCase.class"/>
+ </patternset>
+
+ <antcall target="tests-clustering-unit">
+ <param name="cluster.includes.refid" value="cluster.jk.includes"/>
+ <param name="jboss-junit-configuration" value="SyncModeNUseJvm-${jboss-junit-configuration}"/>
+ </antcall>
+
<server:stop name="node0"/>
<server:stop name="node1"/>
</target>
Modified: branches/JBoss_4_0_3_SP1_CP/testsuite/imports/test-jars.xml
===================================================================
--- branches/JBoss_4_0_3_SP1_CP/testsuite/imports/test-jars.xml 2006-09-27 21:30:18 UTC (rev 57244)
+++ branches/JBoss_4_0_3_SP1_CP/testsuite/imports/test-jars.xml 2006-09-27 22:14:25 UTC (rev 57245)
@@ -979,6 +979,18 @@
</classes>
</war>
+ <!-- build http-jk.jar -->
+ <war warfile="${build.lib}/http-jk.war"
+ webxml="${build.resources}/cluster/http/http-jk/WEB-INF/web.xml">
+ <webinf dir="${build.resources}/cluster/http/http-jk/WEB-INF">
+ <include name="jboss-web.xml"/>
+ <include name="context.xml"/>
+ </webinf>
+ <fileset dir="${build.resources}/cluster/http/http-jk">
+ <include name="*.jsp"/>
+ </fileset>
+ </war>
+
<!-- build http-scoped.jar -->
<copy tofile="${build.resources}/cluster/http/http-scoped/WEB-INF/jboss-web.xml"
file="${build.resources}/cluster/http/http-scoped/jboss-web.xml"
Modified: branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/cluster/test/BaseTest.java
===================================================================
--- branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/cluster/test/BaseTest.java 2006-09-27 21:30:18 UTC (rev 57244)
+++ branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/cluster/test/BaseTest.java 2006-09-27 22:14:25 UTC (rev 57245)
@@ -1,9 +1,24 @@
/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
package org.jboss.test.cluster.test;
import java.io.IOException;
@@ -25,6 +40,10 @@
public abstract class BaseTest
extends JBossClusteredTestCase
{
+ /**
+ * Standard number of ms to pause between http requests
+ * to give session time to replicate
+ */
public static final long DEFAULT_SLEEP = 300;
protected String[] servers_ = null;
@@ -211,4 +230,17 @@
sessionID.setDomain(server);
state.addCookie(sessionID);
}
+
+ protected String stripJvmRoute(String id)
+ {
+ int index = id.indexOf(".");
+ if (index > 0)
+ {
+ return id.substring(0, index);
+ }
+ else
+ {
+ return id;
+ }
+ }
}
Copied: branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/cluster/web/jk (from rev 57244, branches/JBoss_4_0_3_SP1_JBAS-3037/testsuite/src/main/org/jboss/test/cluster/web/jk)
Copied: branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/cluster/web/jk/test (from rev 57244, branches/JBoss_4_0_3_SP1_JBAS-3037/testsuite/src/main/org/jboss/test/cluster/web/jk/test)
Deleted: branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/cluster/web/jk/test/JvmRouteURLRewritingTestCase.java
===================================================================
--- branches/JBoss_4_0_3_SP1_JBAS-3037/testsuite/src/main/org/jboss/test/cluster/web/jk/test/JvmRouteURLRewritingTestCase.java 2006-09-27 21:30:18 UTC (rev 57244)
+++ branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/cluster/web/jk/test/JvmRouteURLRewritingTestCase.java 2006-09-27 22:14:25 UTC (rev 57245)
@@ -1,99 +0,0 @@
-package org.jboss.test.cluster.web.jk.test;
-
-import java.io.IOException;
-import java.net.HttpURLConnection;
-
-import junit.framework.Test;
-
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.jboss.test.JBossClusteredTestCase;
-import org.jboss.test.cluster.test.BaseTest;
-
-public class JvmRouteURLRewritingTestCase extends BaseTest
-{
-
- public JvmRouteURLRewritingTestCase(String name)
- {
- super(name);
- }
-
- public static Test suite() throws Exception
- {
- Test t1 = JBossClusteredTestCase.getDeploySetup(JvmRouteURLRewritingTestCase.class,
- "http-jk.war");
- return t1;
- }
-
- public void testJkFailoverWithURLRewriting() throws Exception
- {
- getLog().debug("Enter testJkFailoverWithURLRewriting()");
-
- // Create an instance of HttpClient.
- HttpClient client = new HttpClient();
-
- String sessId0 = makeGetWithRequestCount(client, baseURL0_, null, "1");
-
- // Fail over to node1
- String sessId1 = makeGetWithRequestCount(client, baseURL1_, sessId0, "2");
-
- // Fail back over to node0
- makeGetWithRequestCount(client, baseURL0_, sessId1, "3");
- }
-
- private String makeGetWithRequestCount(HttpClient client,
- String urlBase,
- String sessionId,
- String expectedCount)
- {
- String url = urlBase + "/http-jk/accessSession.jsp";
- if (sessionId != null)
- {
- url = url + ";jsessionid=" + sessionId;
- }
-
- GetMethod method = new GetMethod(url);
- int responseCode = 0;
- try
- {
- responseCode = client.executeMethod(method);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- fail("HttpClient executeMethod fails." +e.toString());
- }
- assertTrue("Get OK with url: " +url + " responseCode: " +responseCode
- , responseCode == HttpURLConnection.HTTP_OK);
-
- // Validate that the request count is as expected,
- // proving that state replication happened
- Header hdr = method.getResponseHeader("X-TestRequestCount");
- assertNotNull("Got the X-TestRequestCount header", hdr);
- assertEquals("X-TestRequestCount header is correct", expectedCount, hdr.getValue());
-
- // Find out the session id
- hdr = method.getResponseHeader("X-TestJSessionID");
- assertNotNull("Got the X-TestJSessionID header", hdr);
- String id = hdr.getValue();
-
- if (sessionId != null)
- {
- // Check the real session id is correct
- assertEquals("Real session id is correct", stripJvmRoute(sessionId),
- stripJvmRoute(id));
- // Check the session id has changed
- assertFalse("Session id has changed", sessionId.equals(id));
- }
-
- // Read the response body and confirm the URL was properly encoded.
- byte[] responseBody = method.getResponseBody();
- String body = new String(responseBody);
- String expectedURL = "accessSession.jsp;jsessionid=" + id;
- assertTrue("URL encoded properly: " + body, body.indexOf(expectedURL) > -1);
-
- return id;
- }
-
-}
Copied: branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/cluster/web/jk/test/JvmRouteURLRewritingTestCase.java (from rev 57244, branches/JBoss_4_0_3_SP1_JBAS-3037/testsuite/src/main/org/jboss/test/cluster/web/jk/test/JvmRouteURLRewritingTestCase.java)
Copied: branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk (from rev 57244, branches/JBoss_4_0_3_SP1_JBAS-3037/testsuite/src/resources/cluster/http/http-jk)
Copied: branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/WEB-INF (from rev 57244, branches/JBoss_4_0_3_SP1_JBAS-3037/testsuite/src/resources/cluster/http/http-jk/WEB-INF)
Deleted: branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/WEB-INF/context.xml
===================================================================
--- branches/JBoss_4_0_3_SP1_JBAS-3037/testsuite/src/resources/cluster/http/http-jk/WEB-INF/context.xml 2006-09-27 21:30:18 UTC (rev 57244)
+++ branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/WEB-INF/context.xml 2006-09-27 22:14:25 UTC (rev 57245)
@@ -1,17 +0,0 @@
-<!-- Override the default to disable cookies -->
-<Context cookies="false" crossContext="true">
- <!-- Session persistence is disable by default. To enable for all web
- apps set the pathname to a non-empty value:
- <Manager pathname="SESSIONS.ser" />
-
- To enable session persistence for a single web app, add a
- WEB-INF/context.xml
- -->
- <Manager pathname="" />
-
- <!-- Install an InstanceListener to handle the establishment of the run-as
- role for servlet init/destroy events.
- -->
- <InstanceListener>org.jboss.web.tomcat.security.RunAsListener</InstanceListener>
-
-</Context>
Copied: branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/WEB-INF/context.xml (from rev 57244, branches/JBoss_4_0_3_SP1_JBAS-3037/testsuite/src/resources/cluster/http/http-jk/WEB-INF/context.xml)
Deleted: branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/WEB-INF/jboss-web.xml
===================================================================
--- branches/JBoss_4_0_3_SP1_JBAS-3037/testsuite/src/resources/cluster/http/http-jk/WEB-INF/jboss-web.xml 2006-09-27 21:30:18 UTC (rev 57244)
+++ branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/WEB-INF/jboss-web.xml 2006-09-27 22:14:25 UTC (rev 57245)
@@ -1,15 +0,0 @@
-<jboss-web>
- <class-loading>
- <loader-repository>jboss.web:loader=testHA</loader-repository>
- </class-loading>
-
- <!-- Uncomment the security-domain to enable security. You will
- need to edit the htmladaptor login configuration to setup the
- login modules used to authentication users.
- <security-domain>java:/jaas/jmx-console</security-domain>
- -->
- <replication-config>
- <replication-trigger>SET_AND_GET</replication-trigger>
- <replication-granularity>SESSION</replication-granularity>
- </replication-config>
-</jboss-web>
Copied: branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/WEB-INF/jboss-web.xml (from rev 57244, branches/JBoss_4_0_3_SP1_JBAS-3037/testsuite/src/resources/cluster/http/http-jk/WEB-INF/jboss-web.xml)
Deleted: branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/WEB-INF/web.xml
===================================================================
--- branches/JBoss_4_0_3_SP1_JBAS-3037/testsuite/src/resources/cluster/http/http-jk/WEB-INF/web.xml 2006-09-27 21:30:18 UTC (rev 57244)
+++ branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/WEB-INF/web.xml 2006-09-27 22:14:25 UTC (rev 57245)
@@ -1,11 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE web-app PUBLIC
- "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
-
-<web-app>
- <description>Testing HttpSessionRepl</description>
-
- <distributable/>
-
-</web-app>
Copied: branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/WEB-INF/web.xml (from rev 57244, branches/JBoss_4_0_3_SP1_JBAS-3037/testsuite/src/resources/cluster/http/http-jk/WEB-INF/web.xml)
Deleted: branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/accessSession.jsp
===================================================================
--- branches/JBoss_4_0_3_SP1_JBAS-3037/testsuite/src/resources/cluster/http/http-jk/accessSession.jsp 2006-09-27 21:30:18 UTC (rev 57244)
+++ branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/accessSession.jsp 2006-09-27 22:14:25 UTC (rev 57245)
@@ -1,18 +0,0 @@
-<%
- // Use a custom header to pass back the session id
- response.setHeader("X-TestJSessionID", session.getId());
-
- int count = 1;
- Integer attr = (Integer) session.getAttribute("Count");
- if (attr != null)
- {
- count = attr.intValue();
- count++;
- }
- session.setAttribute("Count", new Integer(count));
- // Use a custom header to pass back the count
- response.setHeader("X-TestRequestCount", Integer.toString(count));
-
- // Last, encode a url to ensure that is working
-%>
-<%= response.encodeURL("accessSession.jsp") %>
\ No newline at end of file
Copied: branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/cluster/http/http-jk/accessSession.jsp (from rev 57244, branches/JBoss_4_0_3_SP1_JBAS-3037/testsuite/src/resources/cluster/http/http-jk/accessSession.jsp)
Modified: branches/JBoss_4_0_3_SP1_CP/tomcat/src/main/org/jboss/web/tomcat/tc5/session/JvmRouteValve.java
===================================================================
--- branches/JBoss_4_0_3_SP1_CP/tomcat/src/main/org/jboss/web/tomcat/tc5/session/JvmRouteValve.java 2006-09-27 21:30:18 UTC (rev 57244)
+++ branches/JBoss_4_0_3_SP1_CP/tomcat/src/main/org/jboss/web/tomcat/tc5/session/JvmRouteValve.java 2006-09-27 22:14:25 UTC (rev 57245)
@@ -8,18 +8,14 @@
import java.io.IOException;
import javax.servlet.http.HttpSession;
-import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
import org.apache.catalina.*;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.util.LifecycleSupport;
import org.apache.catalina.valves.ValveBase;
-import org.jboss.util.NestedRuntimeException;
import org.jboss.logging.Logger;
/**
@@ -68,7 +64,6 @@
// Need to check it before let it through. This is ok because this valve is inserted only
// when mod_jk option is configured.
checkJvmRoute(request, response);
-
// let the servlet invokation go through
getNext().invoke(request, response);
}
@@ -96,86 +91,80 @@
}
// Check if incoming session id has JvmRoute appended. If not, append it.
- // TODO. We handle only get session id by cookie only
- if (req.isRequestedSessionIdFromURL())
- {
- // Warning but do nothing
- log_.error("JvmRoutValve.checkJvmRoute(): Can't handle clustering where session id is from URL. Will skip.");
- }
- else
- {
- handleJvmRoute(sessionId, jvmRoute, res);
- }
+ boolean setCookie = !req.isRequestedSessionIdFromURL();
+ handleJvmRoute(sessionId, jvmRoute, res, setCookie);
}
}
-
- protected void handleJvmRoute(String sessionId, String jvmRoute, HttpServletResponse response)
+ protected void handleJvmRoute(String sessionId,
+ String jvmRoute,
+ HttpServletResponse response,
+ boolean setCookie)
{
- // get requested jvmRoute.
+ // Get requested jvmRoute.
// TODO. The current format is assumed to be id.jvmRoute. Can be generalized later.
String requestedJvmRoute = null;
- int ind = sessionId.indexOf(".");
- if (ind > 0)
+ int index = sessionId.lastIndexOf(".");
+ if (index > 0)
{
- requestedJvmRoute = sessionId.substring(sessionId.indexOf(".") + 1, sessionId.length());
+ requestedJvmRoute = sessionId.substring(index + 1, sessionId.length());
}
- String sid = sessionId;
- if (requestedJvmRoute == null)
+ String newId = sessionId;
+ if (!jvmRoute.equals(requestedJvmRoute))
{
- // If this valve is turned on, we assume we have an appendix of jvmRoute. So this request is new.
- sid = sessionId + "." + jvmRoute;
- manager_.setNewSessionCookie(sid, response);
- }
- else if (requestedJvmRoute.equals(jvmRoute))
- {
- return; // Nothing more needs to be done.
- }
- else
- {
- // We just have a failover since jvmRoute does not match. We will replace the old one with the new one.
- if (log_.isDebugEnabled())
+ if (requestedJvmRoute == null)
{
- log_.debug("handleJvmRoute(): We have detected a failover with differen jvmRoute." +
- " old one: " + requestedJvmRoute + " new one: " + jvmRoute + ". Will reset the session id.");
- }
- int index = sessionId.indexOf(".");
- if (index > 0)
+ // If this valve is turned on, we assume we have an appendix of jvmRoute.
+ // So this request is new.
+ newId = sessionId + "." + jvmRoute;
+ }
+ else
{
- String base = sessionId.substring(0, sessionId.indexOf("."));
- sid = base + "." + jvmRoute;
- }
- else
- {
- throw new RuntimeException("JvmRouteVavle.handleJvmRoute(): session id doesn't JvmRoute.");
- }
-
- manager_.setNewSessionCookie(sid, response);
- // Change the sessionId with the new one using local jvmRoute
- ClusteredSession session = null;
- try
- {
- session = (ClusteredSession)manager_.findSession(sessionId);
- // change session id with the new one using local jvmRoute and update cluster if needed.
- if( session != null )
+ // We just had a failover since jvmRoute does not match.
+ // We will replace the old one with the new one.
+ if (log_.isDebugEnabled())
{
- // Note this will trigger a session remove from the super Tomcat class.
- session.resetIdWithRouteInfo(sid);
- if (log_.isDebugEnabled())
- {
- log_.debug("handleJvmRoute(): changed catalina session to= [" + sid + "] old one= [" + sessionId + "]");
- }
+ log_.debug("handleJvmRoute(): We have detected a failover with different jvmRoute." +
+ " old one: " + requestedJvmRoute + " new one: " + jvmRoute + ". Will reset the session id.");
}
+
+ String base = sessionId.substring(0, index);
+ newId = base + "." + jvmRoute;
}
- catch (IOException e)
+
+ resetSessionId(sessionId, newId);
+
+ if (setCookie)
+ manager_.setNewSessionCookie(newId, response);
+ }
+ }
+
+ private void resetSessionId(String oldId, String newId)
+ {
+ // Change the sessionId with the new one using local jvmRoute
+ ClusteredSession session = null;
+ try
+ {
+ session = (ClusteredSession)manager_.findSession(oldId);
+ // change session id with the new one using local jvmRoute and update cluster if needed.
+ if( session != null )
{
+ // Note this will trigger a session remove from the super Tomcat class.
+ session.resetIdWithRouteInfo(newId);
if (log_.isDebugEnabled())
{
- log_.debug("handleJvmRoute(): manager_.findSession() unable to find session= [" + sessionId + "]", e);
+ log_.debug("handleJvmRoute(): changed catalina session to= [" + newId + "] old one= [" + oldId + "]");
}
- throw new NestedRuntimeException("JvmRouteValve.handleJvmRoute(): cannot find session [" + sessionId + "]", e);
}
}
+ catch (IOException e)
+ {
+ if (log_.isDebugEnabled())
+ {
+ log_.debug("resetSessionId(): manager_.findSession() unable to find session= [" + oldId + "]", e);
+ }
+ throw new RuntimeException("JvmRouteValve.resetSessionId(): cannot find session [" + oldId + "]", e);
+ }
}
// Lifecylce-interface
More information about the jboss-cvs-commits
mailing list