public class JvmRouteBinderValve extends ValveBase implements ClusterValve
Add this Valve to your cluster definition at conf/server.xml .
<Cluster> <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve" /> </Cluster>A Trick:
Lifecycle.SingleUse
Modifier and Type | Field and Description |
---|---|
protected CatalinaCluster |
cluster
the cluster
|
protected boolean |
enabled
enabled this component
|
static Log |
log |
protected long |
numberOfSessions
number of session that no at this tomcat instance hosted
|
protected java.lang.String |
sessionIdAttribute |
protected static StringManager |
sm
The string manager for this package.
|
asyncSupported, container, containerLog, next
mserver
AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
Constructor and Description |
---|
JvmRouteBinderValve() |
Modifier and Type | Method and Description |
---|---|
protected void |
changeRequestSessionID(Request request,
java.lang.String sessionId,
java.lang.String newSessionID)
Change Request Session id
|
protected void |
changeSessionID(Request request,
java.lang.String sessionId,
java.lang.String newSessionID,
Session catalinaSession)
change session id and send to all cluster nodes
|
CatalinaCluster |
getCluster()
Returns the cluster the cluster deployer is associated with
|
boolean |
getEnabled() |
protected java.lang.String |
getLocalJvmRoute(Request request)
get jvmroute from engine
|
protected Manager |
getManager(Request request)
get ClusterManager
|
long |
getNumberOfSessions() |
java.lang.String |
getSessionIdAttribute()
set session id attribute to failed node for request.
|
protected void |
handleJvmRoute(Request request,
java.lang.String sessionId,
java.lang.String localJvmRoute)
Handle jvmRoute stickiness after tomcat instance failed.
|
protected void |
handlePossibleTurnover(Request request)
handle possible session turn over.
|
void |
invoke(Request request,
Response response)
Detect possible the JVMRoute change at cluster backup node..
|
void |
setCluster(CatalinaCluster cluster)
Associates the cluster deployer with a cluster
|
void |
setEnabled(boolean enabled) |
void |
setSessionIdAttribute(java.lang.String sessionIdAttribute)
get name of failed request session attribute
|
protected void |
startInternal()
Start this component and implement the requirements
of
LifecycleBase.startInternal() . |
protected void |
stopInternal()
Stop this component and implement the requirements
of
LifecycleBase.stopInternal() . |
backgroundProcess, event, getContainer, getDomainInternal, getNext, getObjectNameKeyProperties, initInternal, isAsyncSupported, setAsyncSupported, setContainer, setNext, toString
destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister
addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, init, removeLifecycleListener, setState, setState, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
backgroundProcess, event, getNext, isAsyncSupported, setNext
public static final Log log
protected CatalinaCluster cluster
protected static final StringManager sm
protected boolean enabled
protected long numberOfSessions
protected java.lang.String sessionIdAttribute
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, 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 occurredServletException
- if a servlet error has occurredprotected void handlePossibleTurnover(Request request)
request
- current requesthandleJvmRoute(Request, 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, java.lang.String sessionId, java.lang.String localJvmRoute)
request
- current requestsessionId
- request SessionID from CookielocalJvmRoute
- local jvmRouteprotected void changeSessionID(Request request, java.lang.String sessionId, java.lang.String newSessionID, Session catalinaSession)
request
- current requestsessionId
- original session idnewSessionID
- new session id for node migrationcatalinaSession
- current session with original session idprotected void changeRequestSessionID(Request request, java.lang.String sessionId, java.lang.String newSessionID)
request
- current requestsessionId
- original session idnewSessionID
- new session id for node migrationprotected void startInternal() throws LifecycleException
LifecycleBase.startInternal()
.startInternal
in class ValveBase
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedprotected void stopInternal() throws LifecycleException
LifecycleBase.stopInternal()
.stopInternal
in class ValveBase
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedCopyright © 2000-2018 Apache Software Foundation. All Rights Reserved.