|
||||||||||
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.cluster.session.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
JvmRouteSessionIDBinderListener
with
JvmRouteSessionIDBinderListenerLifecycle
Add this Valve to your clustered application or setup it to context default
conf/enginename/hostname/context.xml.default for all host application
<Context> <Valve className="org.apache.catalina.cluster.session.JvmRouteBinderValve" /> </Context>
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 org.apache.commons.logging.Log |
log
|
protected Manager |
manager
Session Manager for and app manager |
protected boolean |
managerCheck
is manager a distrbuted |
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(java.lang.String sessionId,
Request request,
Response response,
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. |
boolean |
getEnabled()
|
java.lang.String |
getInfo()
Return descriptive information about this implementation. |
protected java.lang.String |
getLocalJvmRoute()
get jvmroute from engine |
protected Manager |
getManager()
get Cluster DeltaManager |
long |
getNumberOfSessions()
|
java.lang.String |
getSessionIdAttribute()
set session id attribute to failed node for request. |
protected void |
handleJvmRoute(java.lang.String sessionId,
java.lang.String localJvmRoute,
Request request,
Response response)
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(java.lang.String sessionId,
java.lang.String newSessionID)
Send the changed Sessionid to all clusternodes. |
void |
setEnabled(boolean enabled)
|
protected void |
setNewSessionCookie(java.lang.String sessionId,
Request request,
Response response)
Sets a new cookie for the given session id and response and see {@link org.apache.catalina.connector.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, getContainer, getContainerName, getController, getDomain, getNext, getObjectName, getParentName, postDeregister, postRegister, preDeregister, preRegister, setContainer, setController, setNext, setObjectName |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static org.apache.commons.logging.Log log
protected static final java.lang.String info
protected CatalinaCluster cluster
protected Manager manager
manager
protected boolean managerCheck
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
- response
- handleJvmRoute(String, String, Request,
Response)
protected java.lang.String getLocalJvmRoute()
protected Manager getManager()
protected void handleJvmRoute(java.lang.String sessionId, java.lang.String localJvmRoute, Request request, Response response)
sessionId
- request SessionID from CookielocalJvmRoute
- local jvmRouteresponse
- Tomcat Responseprotected void changeSessionID(java.lang.String sessionId, Request request, Response response, java.lang.String newSessionID, Session catalinaSession)
sessionId
- original session idrequest
- response
- newSessionID
- new session id for node migrationcatalinaSession
- current session with original session idprotected void sendSessionIDClusterBackup(java.lang.String sessionId, java.lang.String newSessionID)
sessionId
- current failed sessionidnewSessionID
- new session id, bind to the new cluster nodeJvmRouteSessionIDBinderListener.messageReceived(ClusterMessage)
protected void setNewSessionCookie(java.lang.String sessionId, Request request, Response response)
sessionId
- The session idresponse
- Tomcat Responsepublic 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 |