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.
Lifecycle.SingleUse
Modifier and Type | Field and Description |
---|---|
protected java.lang.ThreadLocal<java.util.ArrayList<DeltaSession>> |
crossContextSessions
crossContext session container
|
protected boolean |
doProcessingStats
doProcessingStats (default = off)
|
protected java.util.regex.Pattern |
filter
Filter expression
|
protected long |
lastSendTime |
protected long |
nrOfCrossContextSendRequests |
protected long |
nrOfFilterRequests |
protected long |
nrOfRequests |
protected long |
nrOfSendRequests |
protected boolean |
primaryIndicator
must primary change indicator set
|
protected java.lang.String |
primaryIndicatorName
Name of primary change indicator as request attribute
|
protected static StringManager |
sm
The StringManager for this package.
|
protected long |
totalRequestTime |
protected long |
totalSendTime |
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 |
---|
ReplicationValve() |
Modifier and Type | Method and Description |
---|---|
protected void |
createPrimaryIndicator(Request request)
Mark Request that processed at primary node with attribute
primaryIndicatorName
|
boolean |
doStatistics()
Calc processing stats
|
CatalinaCluster |
getCluster()
Returns the cluster the cluster deployer is associated with
|
java.lang.String |
getFilter() |
long |
getLastSendTime() |
long |
getNrOfCrossContextSendRequests() |
long |
getNrOfFilterRequests() |
long |
getNrOfRequests() |
long |
getNrOfSendRequests() |
java.lang.String |
getPrimaryIndicatorName() |
long |
getTotalRequestTime() |
long |
getTotalSendTime() |
void |
invoke(Request request,
Response response)
Log the interesting request parameters, invoke the next Valve in the
sequence, and log the interesting response parameters.
|
boolean |
isPrimaryIndicator() |
protected boolean |
isRequestWithoutSessionChange(java.lang.String uri)
is request without possible session change
|
void |
registerReplicationSession(DeltaSession session)
Register all cross context sessions inside endAccess.
|
protected void |
resetDeltaRequest(Session session)
Reset DeltaRequest from session
|
protected void |
resetReplicationRequest(Request request,
boolean isCrossContext)
Fix memory leak for long sessions with many changes, when no backup member exists!
|
void |
resetStatistics()
reset the active statistics
|
protected void |
send(ClusterManager manager,
java.lang.String sessionId)
send manager requestCompleted message to cluster
|
protected void |
sendCrossContextSession()
Send all changed cross context sessions to backups
|
protected void |
sendInvalidSessions(ClusterManager manager)
check for session invalidations
|
protected void |
sendMessage(Session session,
ClusterManager manager)
Send message delta message from request session
|
protected void |
sendReplicationMessage(Request request,
long totalstart,
boolean isCrossContext,
ClusterManager clusterManager) |
protected void |
sendSessionReplicationMessage(Request request,
ClusterManager manager)
Send Cluster Replication Request
|
void |
setCluster(CatalinaCluster cluster)
Associates the cluster deployer with a cluster
|
void |
setFilter(java.lang.String filter)
compile filter string to regular expression
|
void |
setPrimaryIndicator(boolean primaryIndicator) |
void |
setPrimaryIndicatorName(java.lang.String primaryIndicatorName) |
void |
setStatistics(boolean doProcessingStats)
Set Calc processing stats
|
protected void |
startInternal()
Start this component and implement the requirements
of
LifecycleBase.startInternal() . |
protected void |
updateStats(long requestTime,
long clusterTime)
Protocol cluster replications stats
|
backgroundProcess, event, getContainer, getDomainInternal, getNext, getObjectNameKeyProperties, initInternal, isAsyncSupported, setAsyncSupported, setContainer, setNext, stopInternal, 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
protected static final StringManager sm
protected java.util.regex.Pattern filter
protected final java.lang.ThreadLocal<java.util.ArrayList<DeltaSession>> crossContextSessions
protected boolean doProcessingStats
protected long totalRequestTime
protected long totalSendTime
protected long nrOfRequests
protected long lastSendTime
protected long nrOfFilterRequests
protected long nrOfSendRequests
protected long nrOfCrossContextSendRequests
protected boolean primaryIndicator
protected java.lang.String primaryIndicatorName
public CatalinaCluster getCluster()
ClusterValve
getCluster
in interface ClusterValve
public void setCluster(CatalinaCluster cluster)
ClusterValve
setCluster
in interface ClusterValve
cluster
- The cluster to set.public java.lang.String getFilter()
public void setFilter(java.lang.String filter)
filter
- The filter to set.Pattern.compile(java.lang.String)
public boolean isPrimaryIndicator()
public void setPrimaryIndicator(boolean primaryIndicator)
primaryIndicator
- The primaryIndicator to set.public java.lang.String getPrimaryIndicatorName()
public void setPrimaryIndicatorName(java.lang.String primaryIndicatorName)
primaryIndicatorName
- The primaryIndicatorName to set.public boolean doStatistics()
public void setStatistics(boolean doProcessingStats)
resetStatistics()
public long getLastSendTime()
public long getNrOfRequests()
public long getNrOfFilterRequests()
public long getNrOfCrossContextSendRequests()
public long getNrOfSendRequests()
public long getTotalRequestTime()
public long getTotalSendTime()
public void registerReplicationSession(DeltaSession session)
session
- cross context sessionpublic void invoke(Request request, Response response) throws java.io.IOException, ServletException
invoke
in interface Valve
invoke
in class ValveBase
request
- The servlet request to be processedresponse
- The servlet response to be createdjava.io.IOException
- if an input/output error occursServletException
- if a servlet error occurspublic void resetStatistics()
protected 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 sendReplicationMessage(Request request, long totalstart, boolean isCrossContext, ClusterManager clusterManager)
request
- totalstart
- isCrossContext
- clusterManager
- protected void sendCrossContextSession()
protected void resetReplicationRequest(Request request, boolean isCrossContext)
request
- current request after response is generatedisCrossContext
- check crosscontext threadlocalprotected void resetDeltaRequest(Session session)
session
- HttpSession from current request or cross context sessionprotected void sendSessionReplicationMessage(Request request, ClusterManager manager)
request
- current requestmanager
- session managerprotected void sendMessage(Session session, ClusterManager manager)
session
- current sessionmanager
- session managerprotected void send(ClusterManager manager, java.lang.String sessionId)
manager
- SessionManagersessionId
- sessionid from the managerDeltaManager.requestCompleted(String)
,
SimpleTcpCluster.send(ClusterMessage)
protected void sendInvalidSessions(ClusterManager manager)
manager
- protected boolean isRequestWithoutSessionChange(java.lang.String uri)
uri
- The request uriprotected void updateStats(long requestTime, long clusterTime)
requestTime
- clusterTime
- protected void createPrimaryIndicator(Request request) throws java.io.IOException
request
- java.io.IOException
Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.