|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.catalina.valves.ValveBase
org.apache.catalina.ha.session.JvmRouteBinderValve
public class JvmRouteBinderValve
Valve to handle Tomcat jvmRoute takeover using mod_jk module after node
failure. After a node crashed the next request going to other cluster node.
Now the answering from apache is slower ( make some error handshaking. Very
bad with apache at my windows.). We rewrite now the cookie jsessionid
information to the backup cluster node. After the next response all client
request goes direct to the backup node. The change sessionid send also to all
other cluster nodes. Well, now the session stickyness work directly to the
backup node and traffic don't go back too restarted cluster nodes!
At all cluster node you must configure the as ClusterListener since 5.5.10
JvmRouteSessionIDBinderListener
or before with
org.apache.catalina.ha.session.JvmRouteSessionIDBinderListenerLifecycle.
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>
<Hostr> <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve" /> </Hostr>Trick:
Field Summary | |
---|---|
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? |
Fields inherited from class org.apache.catalina.valves.ValveBase |
---|
container, containerLog, controller, domain, mserver, next, oname |
Fields inherited from interface org.apache.catalina.Lifecycle |
---|
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, DESTROY_EVENT, INIT_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT |
Constructor Summary | |
---|---|
JvmRouteBinderValve()
|
Method Summary | |
---|---|
void |
addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component. |
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)
Sets a new cookie for the given session id and response and see Request.configureSessionCookie(javax.servlet.http.Cookie) |
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. |
Methods inherited from class org.apache.catalina.valves.ValveBase |
---|
backgroundProcess, createObjectName, event, getContainer, getContainerName, getController, getDomain, getNext, getObjectName, getParentName, postDeregister, postRegister, preDeregister, preRegister, setContainer, setController, setNext, setObjectName, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.catalina.Valve |
---|
backgroundProcess, event, getNext, setNext |
Field Detail |
---|
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
Constructor Detail |
---|
public JvmRouteBinderValve()
Method Detail |
---|
public java.lang.String getInfo()
getInfo
in interface Valve
getInfo
in class ValveBase
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 processed
java.io.IOException
- if an input/output error has occurred
javax.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 request
protected Manager getManager(Request request)
request
- current request
public 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 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.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
reported
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |