Package org.apache.catalina.ha.tcp
Class ReplicationValve
- java.lang.Object
- 
- org.apache.catalina.util.LifecycleBase
- 
- org.apache.catalina.util.LifecycleMBeanBase
- 
- org.apache.catalina.valves.ValveBase
- 
- org.apache.catalina.ha.tcp.ReplicationValve
 
 
 
 
- 
- All Implemented Interfaces:
- javax.management.MBeanRegistration,- Contained,- ClusterValve,- JmxEnabled,- Lifecycle,- Valve
 
 public class ReplicationValve extends ValveBase implements ClusterValve Implementation of a Valve that logs interesting contents from the specified Request (before processing) and the corresponding Response (after processing). It is especially useful in debugging problems related to headers and cookies. This Valve may be attached to any Container, depending on the granularity of the logging you wish to perform. primaryIndicator=true, then the request attribute org.apache.catalina.ha.tcp.isPrimarySession. is set true, when request processing is at sessions primary node. - Author:
- Craig R. McClanahan, Peter Rossbach
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.apache.catalina.LifecycleLifecycle.SingleUse
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected java.lang.ThreadLocal<java.util.ArrayList<DeltaSession>>crossContextSessionscrossContext session containerprotected booleandoProcessingStatsdoProcessingStats (default = off)protected java.util.regex.PatternfilterFilter expressionprotected longlastSendTimeprotected longnrOfCrossContextSendRequestsprotected longnrOfFilterRequestsprotected longnrOfRequestsprotected longnrOfSendRequestsprotected booleanprimaryIndicatormust primary change indicator setprotected java.lang.StringprimaryIndicatorNameName of primary change indicator as request attributeprotected static StringManagersmThe StringManager for this package.protected longtotalRequestTimeprotected longtotalSendTime- 
Fields inherited from class org.apache.catalina.valves.ValveBaseasyncSupported, container, containerLog, next
 - 
Fields inherited from class org.apache.catalina.util.LifecycleMBeanBasemserver
 - 
Fields inherited from interface org.apache.catalina.LifecycleAFTER_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 SummaryConstructors Constructor Description ReplicationValve()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcreatePrimaryIndicator(Request request)Mark Request that processed at primary node with attribute primaryIndicatorNamebooleandoStatistics()Calc processing statsCatalinaClustergetCluster()Returns the cluster the cluster deployer is associated withjava.lang.StringgetFilter()longgetLastSendTime()longgetNrOfCrossContextSendRequests()longgetNrOfFilterRequests()longgetNrOfRequests()longgetNrOfSendRequests()java.lang.StringgetPrimaryIndicatorName()longgetTotalRequestTime()longgetTotalSendTime()voidinvoke(Request request, Response response)Log the interesting request parameters, invoke the next Valve in the sequence, and log the interesting response parameters.booleanisPrimaryIndicator()protected booleanisRequestWithoutSessionChange(java.lang.String uri)is request without possible session changevoidregisterReplicationSession(DeltaSession session)Register all cross context sessions inside endAccess.protected voidresetDeltaRequest(Session session)Reset DeltaRequest from sessionprotected voidresetReplicationRequest(Request request, boolean isCrossContext)Fix memory leak for long sessions with many changes, when no backup member exists!voidresetStatistics()reset the active statisticsprotected voidsend(ClusterManager manager, java.lang.String sessionId)send manager requestCompleted message to clusterprotected voidsendCrossContextSession()Send all changed cross context sessions to backupsprotected voidsendInvalidSessions(ClusterManager manager)check for session invalidationsprotected voidsendMessage(Session session, ClusterManager manager)Send message delta message from request sessionprotected voidsendReplicationMessage(Request request, long totalstart, boolean isCrossContext, ClusterManager clusterManager)protected voidsendSessionReplicationMessage(Request request, ClusterManager manager)Send Cluster Replication RequestvoidsetCluster(CatalinaCluster cluster)Associates the cluster deployer with a clustervoidsetFilter(java.lang.String filter)compile filter string to regular expressionvoidsetPrimaryIndicator(boolean primaryIndicator)voidsetPrimaryIndicatorName(java.lang.String primaryIndicatorName)voidsetStatistics(boolean doProcessingStats)Set Calc processing statsprotected voidstartInternal()Start this component and implement the requirements ofLifecycleBase.startInternal().protected voidupdateStats(long requestTime, long clusterTime)Protocol cluster replications stats- 
Methods inherited from class org.apache.catalina.valves.ValveBasebackgroundProcess, getContainer, getDomainInternal, getNext, getObjectNameKeyProperties, initInternal, isAsyncSupported, setAsyncSupported, setContainer, setNext, stopInternal, toString
 - 
Methods inherited from class org.apache.catalina.util.LifecycleMBeanBasedestroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister
 - 
Methods inherited from class org.apache.catalina.util.LifecycleBaseaddLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface org.apache.catalina.ValvebackgroundProcess, getNext, isAsyncSupported, setNext
 
- 
 
- 
- 
- 
Field Detail- 
smprotected static final StringManager sm The StringManager for this package.
 - 
filterprotected java.util.regex.Pattern filter Filter expression
 - 
crossContextSessionsprotected final java.lang.ThreadLocal<java.util.ArrayList<DeltaSession>> crossContextSessions crossContext session container
 - 
doProcessingStatsprotected boolean doProcessingStats doProcessingStats (default = off)
 - 
totalRequestTimeprotected volatile long totalRequestTime 
 - 
totalSendTimeprotected volatile long totalSendTime 
 - 
nrOfRequestsprotected volatile long nrOfRequests 
 - 
lastSendTimeprotected volatile long lastSendTime 
 - 
nrOfFilterRequestsprotected volatile long nrOfFilterRequests 
 - 
nrOfSendRequestsprotected volatile long nrOfSendRequests 
 - 
nrOfCrossContextSendRequestsprotected volatile long nrOfCrossContextSendRequests 
 - 
primaryIndicatorprotected boolean primaryIndicator must primary change indicator set
 - 
primaryIndicatorNameprotected java.lang.String primaryIndicatorName Name of primary change indicator as request attribute
 
- 
 - 
Method Detail- 
getClusterpublic CatalinaCluster getCluster() Description copied from interface:ClusterValveReturns the cluster the cluster deployer is associated with- Specified by:
- getClusterin interface- ClusterValve
- Returns:
- the cluster.
 
 - 
setClusterpublic void setCluster(CatalinaCluster cluster) Description copied from interface:ClusterValveAssociates the cluster deployer with a cluster- Specified by:
- setClusterin interface- ClusterValve
- Parameters:
- cluster- The cluster to set.
 
 - 
getFilterpublic java.lang.String getFilter() - Returns:
- the filter
 
 - 
setFilterpublic void setFilter(java.lang.String filter) compile filter string to regular expression- Parameters:
- filter- The filter to set.
- See Also:
- Pattern.compile(java.lang.String)
 
 - 
isPrimaryIndicatorpublic boolean isPrimaryIndicator() - Returns:
- the primaryIndicator.
 
 - 
setPrimaryIndicatorpublic void setPrimaryIndicator(boolean primaryIndicator) - Parameters:
- primaryIndicator- The primaryIndicator to set.
 
 - 
getPrimaryIndicatorNamepublic java.lang.String getPrimaryIndicatorName() - Returns:
- the primaryIndicatorName.
 
 - 
setPrimaryIndicatorNamepublic void setPrimaryIndicatorName(java.lang.String primaryIndicatorName) - Parameters:
- primaryIndicatorName- The primaryIndicatorName to set.
 
 - 
doStatisticspublic boolean doStatistics() Calc processing stats- Returns:
- trueif statistics are enabled
 
 - 
setStatisticspublic void setStatistics(boolean doProcessingStats) Set Calc processing stats- Parameters:
- doProcessingStats- New flag value
- See Also:
- resetStatistics()
 
 - 
getLastSendTimepublic long getLastSendTime() - Returns:
- the lastSendTime.
 
 - 
getNrOfRequestspublic long getNrOfRequests() - Returns:
- the nrOfRequests.
 
 - 
getNrOfFilterRequestspublic long getNrOfFilterRequests() - Returns:
- the nrOfFilterRequests.
 
 - 
getNrOfCrossContextSendRequestspublic long getNrOfCrossContextSendRequests() - Returns:
- the nrOfCrossContextSendRequests.
 
 - 
getNrOfSendRequestspublic long getNrOfSendRequests() - Returns:
- the nrOfSendRequests.
 
 - 
getTotalRequestTimepublic long getTotalRequestTime() - Returns:
- the totalRequestTime.
 
 - 
getTotalSendTimepublic long getTotalSendTime() - Returns:
- the totalSendTime.
 
 - 
registerReplicationSessionpublic void registerReplicationSession(DeltaSession session) Register all cross context sessions inside endAccess. Use a list with contains check, that the Portlet API can include a lot of fragments from same or different applications with session changes.- Parameters:
- session- cross context session
 
 - 
invokepublic void invoke(Request request, Response response) throws java.io.IOException, ServletException Log the interesting request parameters, invoke the next Valve in the sequence, and log the interesting response parameters.- Specified by:
- invokein interface- Valve
- Parameters:
- request- The servlet request to be processed
- response- The servlet response to be created
- Throws:
- java.io.IOException- if an input/output error occurs
- ServletException- if a servlet error occurs
 
 - 
resetStatisticspublic void resetStatistics() reset the active statistics
 - 
startInternalprotected void startInternal() throws LifecycleExceptionStart this component and implement the requirements ofLifecycleBase.startInternal().- Overrides:
- startInternalin class- ValveBase
- Throws:
- LifecycleException- if this component detects a fatal error that prevents this component from being used
 
 - 
sendReplicationMessageprotected void sendReplicationMessage(Request request, long totalstart, boolean isCrossContext, ClusterManager clusterManager) 
 - 
sendCrossContextSessionprotected void sendCrossContextSession() Send all changed cross context sessions to backups
 - 
resetReplicationRequestprotected void resetReplicationRequest(Request request, boolean isCrossContext) Fix memory leak for long sessions with many changes, when no backup member exists!- Parameters:
- request- current request after response is generated
- isCrossContext- check crosscontext threadlocal
 
 - 
resetDeltaRequestprotected void resetDeltaRequest(Session session) Reset DeltaRequest from session- Parameters:
- session- HttpSession from current request or cross context session
 
 - 
sendSessionReplicationMessageprotected void sendSessionReplicationMessage(Request request, ClusterManager manager) Send Cluster Replication Request- Parameters:
- request- current request
- manager- session manager
 
 - 
sendMessageprotected void sendMessage(Session session, ClusterManager manager) Send message delta message from request session- Parameters:
- session- current session
- manager- session manager
 
 - 
sendprotected void send(ClusterManager manager, java.lang.String sessionId) send manager requestCompleted message to cluster- Parameters:
- manager- SessionManager
- sessionId- sessionid from the manager
- See Also:
- DeltaManager.requestCompleted(String),- SimpleTcpCluster.send(ClusterMessage)
 
 - 
sendInvalidSessionsprotected void sendInvalidSessions(ClusterManager manager) check for session invalidations- Parameters:
- manager- Associated manager
 
 - 
isRequestWithoutSessionChangeprotected boolean isRequestWithoutSessionChange(java.lang.String uri) is request without possible session change- Parameters:
- uri- The request uri
- Returns:
- True if no session change
 
 - 
updateStatsprotected void updateStats(long requestTime, long clusterTime)Protocol cluster replications stats- Parameters:
- requestTime- Request time
- clusterTime- Cluster time
 
 - 
createPrimaryIndicatorprotected void createPrimaryIndicator(Request request) throws java.io.IOException Mark Request that processed at primary node with attribute primaryIndicatorName- Parameters:
- request- The Servlet request
- Throws:
- java.io.IOException- IO error finding session
 
 
- 
 
-