org.apache.catalina.ha.session
public class JvmRouteBinderValve extends ValveBase implements ClusterValve, Lifecycle
For this valve to function correctly, so that all nodes of the cluster
receive the sessionid change notifications that it generates, the following
ClusterListener MUST be configured at all nodes of the cluster:
JvmRouteSessionIDBinderListener
since Tomcat 5.5.10, and both
JvmRouteSessionIDBinderListener and JvmRouteSessionIDBinderLifecycleListener
for earlier versions of Tomcat.
Add this Valve to your host definition at conf/server.xml .
Since 5.5.10 as direct cluster valve:
<Cluster> <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve" /> </Cluster>
<Host> <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve" /> </Host>A Trick:
Modifier and Type | Field and Description |
---|---|
protected CatalinaCluster |
cluster
the cluster
|
protected boolean |
enabled
enabled this component
|
protected static java.lang.String |
info
The descriptive information about this implementation.
|
protected LifecycleSupport |
lifecycle
The lifecycle event support for this component.
|
static Log |
log |
protected long |
numberOfSessions
number of session that no at this tomcat instanz hosted
|
protected java.lang.String |
sessionIdAttribute |
protected StringManager |
sm
The string manager for this package.
|
protected boolean |
started
Has this component been started yet?
|
container, containerLog, controller, domain, mserver, next, oname
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, DESTROY_EVENT, INIT_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
Constructor and Description |
---|
JvmRouteBinderValve() |
Modifier and Type | Method and Description |
---|---|
void |
addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.
|
protected void |
changeRequestSessionID(Request request,
Response response,
java.lang.String sessionId,
java.lang.String newSessionID)
Change Request Session id
|
protected void |
changeSessionID(Request request,
Response response,
java.lang.String sessionId,
java.lang.String newSessionID,
Session catalinaSession)
change session id and send to all cluster nodes
|
LifecycleListener[] |
findLifecycleListeners()
Get the lifecycle listeners associated with this lifecycle.
|
CatalinaCluster |
getCluster()
Returns the cluster the cluster deployer is associated with
|
boolean |
getEnabled() |
java.lang.String |
getInfo()
Return descriptive information about this implementation.
|
protected java.lang.String |
getLocalJvmRoute(Request request)
get jvmroute from engine
|
protected Manager |
getManager(Request request)
get Cluster DeltaManager
|
long |
getNumberOfSessions() |
java.lang.String |
getSessionIdAttribute()
set session id attribute to failed node for request.
|
protected void |
handleJvmRoute(Request request,
Response response,
java.lang.String sessionId,
java.lang.String localJvmRoute)
Handle jvmRoute stickyness after tomcat instance failed.
|
protected void |
handlePossibleTurnover(Request request,
Response response)
handle possible session turn over.
|
void |
invoke(Request request,
Response response)
Detect possible the JVMRoute change at cluster backup node..
|
void |
removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.
|
protected void |
sendSessionIDClusterBackup(ClusterManager manager,
Request request,
java.lang.String sessionId,
java.lang.String newSessionID)
Send the changed Sessionid to all clusternodes.
|
void |
setCluster(CatalinaCluster cluster)
Associates the cluster deployer with a cluster
|
void |
setEnabled(boolean enabled) |
protected void |
setNewSessionCookie(Request request,
Response response,
java.lang.String sessionId)
Deprecated.
|
void |
setSessionIdAttribute(java.lang.String sessionIdAttribute)
get name of failed reqeust session attribute
|
void |
start()
Prepare for the beginning of active use of the public methods of this
component.
|
void |
stop()
Gracefully terminate the active use of the public methods of this
component.
|
backgroundProcess, createObjectName, event, getContainer, getContainerName, getController, getDomain, getNext, getObjectName, getParentName, postDeregister, postRegister, preDeregister, preRegister, setContainer, setController, setNext, setObjectName, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
backgroundProcess, event, getNext, setNext
public static Log log
protected static final java.lang.String info
protected CatalinaCluster cluster
protected StringManager sm
protected boolean started
protected boolean enabled
protected long numberOfSessions
protected java.lang.String sessionIdAttribute
protected LifecycleSupport lifecycle
public java.lang.String getInfo()
public java.lang.String getSessionIdAttribute()
public void setSessionIdAttribute(java.lang.String sessionIdAttribute)
sessionIdAttribute
- The sessionIdAttribute to set.public long getNumberOfSessions()
public boolean getEnabled()
public void setEnabled(boolean enabled)
enabled
- The enabled to set.public void invoke(Request request, Response response) throws java.io.IOException, javax.servlet.ServletException
invoke
in interface Valve
invoke
in class ValveBase
request
- tomcat request being processedresponse
- tomcat response being processedjava.io.IOException
- if an input/output error has occurredjavax.servlet.ServletException
- if a servlet error has occurredprotected void handlePossibleTurnover(Request request, Response response)
request
- current requestresponse
- current responsehandleJvmRoute(Request, Response, String, String)
protected java.lang.String getLocalJvmRoute(Request request)
request
- current requestprotected Manager getManager(Request request)
request
- current requestpublic CatalinaCluster getCluster()
ClusterValve
getCluster
in interface ClusterValve
public void setCluster(CatalinaCluster cluster)
ClusterValve
setCluster
in interface ClusterValve
cluster
- The cluster to set.protected void handleJvmRoute(Request request, Response response, java.lang.String sessionId, java.lang.String localJvmRoute)
request
- current requestresponse
- Tomcat ResponsesessionId
- request SessionID from CookielocalJvmRoute
- local jvmRouteprotected void changeSessionID(Request request, Response response, java.lang.String sessionId, java.lang.String newSessionID, Session catalinaSession)
request
- current requestresponse
- current responsesessionId
- original session idnewSessionID
- new session id for node migrationcatalinaSession
- current session with original session idprotected void changeRequestSessionID(Request request, Response response, java.lang.String sessionId, java.lang.String newSessionID)
request
- current requestresponse
- current responsesessionId
- original session idnewSessionID
- new session id for node migrationprotected void sendSessionIDClusterBackup(ClusterManager manager, Request request, java.lang.String sessionId, java.lang.String newSessionID)
manager
- ClusterManagersessionId
- current failed sessionidnewSessionID
- new session id, bind to the new cluster nodeJvmRouteSessionIDBinderListener.messageReceived(ClusterMessage)
protected void setNewSessionCookie(Request request, Response response, java.lang.String sessionId)
Request.changeSessionId(String)
Request.configureSessionCookie(javax.servlet.http.Cookie)
request
- current requestresponse
- Tomcat ResponsesessionId
- The session idpublic void addLifecycleListener(LifecycleListener listener)
addLifecycleListener
in interface Lifecycle
listener
- The listener to addpublic LifecycleListener[] findLifecycleListeners()
findLifecycleListeners
in interface Lifecycle
public void removeLifecycleListener(LifecycleListener listener)
removeLifecycleListener
in interface Lifecycle
listener
- The listener to addpublic void start() throws LifecycleException
configure()
,
and before any of the public methods of the component are utilized.start
in interface Lifecycle
LifecycleException
- if this component detects a fatal error that prevents this
component from being usedpublic void stop() throws LifecycleException
stop
in interface Lifecycle
LifecycleException
- if this component detects a fatal error that needs to be
reportedCopyright © 2000-2014 Apache Software Foundation. All Rights Reserved.