use of org.apache.catalina.ha.ClusterManager in project tomcat70 by apache.
the class ReplicationValve method invoke.
/**
* Log the interesting request parameters, invoke the next Valve in the
* sequence, and log the interesting response parameters.
*
* @param request The servlet request to be processed
* @param response The servlet response to be created
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
*/
@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
long totalstart = 0;
// this happens before the request
if (doStatistics()) {
totalstart = System.currentTimeMillis();
}
if (primaryIndicator) {
createPrimaryIndicator(request);
}
Context context = request.getContext();
boolean isCrossContext = context != null && context instanceof StandardContext && ((StandardContext) context).getCrossContext();
try {
if (isCrossContext) {
if (log.isDebugEnabled())
log.debug(sm.getString("ReplicationValve.crossContext.add"));
// FIXME add Pool of Arraylists
crossContextSessions.set(new ArrayList<DeltaSession>());
}
getNext().invoke(request, response);
if (context != null && cluster != null && context.getManager() instanceof ClusterManager) {
ClusterManager clusterManager = (ClusterManager) context.getManager();
// at host level - hopefully!
if (cluster.getManager(clusterManager.getName()) == null)
return;
if (cluster.hasMembers()) {
sendReplicationMessage(request, totalstart, isCrossContext, clusterManager, cluster);
} else {
resetReplicationRequest(request, isCrossContext);
}
}
} finally {
// Don't register this request session again!
if (isCrossContext) {
if (log.isDebugEnabled())
log.debug(sm.getString("ReplicationValve.crossContext.remove"));
// crossContextSessions.remove() only exist at Java 5
// register ArrayList at a pool
crossContextSessions.set(null);
}
}
}
Aggregations