use of org.apache.catalina.ha.session.DeltaSession in project tomcat70 by apache.
the class ReplicationValve method resetReplicationRequest.
/**
* Fix memory leak for long sessions with many changes, when no backup member exists!
* @param request current request after response is generated
* @param isCrossContext check crosscontext threadlocal
*/
protected void resetReplicationRequest(Request request, boolean isCrossContext) {
Session contextSession = request.getSessionInternal(false);
if (contextSession instanceof DeltaSession) {
resetDeltaRequest(contextSession);
((DeltaSession) contextSession).setPrimarySession(true);
}
if (isCrossContext) {
List<DeltaSession> sessions = crossContextSessions.get();
if (sessions != null && sessions.size() > 0) {
Iterator<DeltaSession> iter = sessions.iterator();
for (; iter.hasNext(); ) {
Session session = iter.next();
resetDeltaRequest(session);
if (session instanceof DeltaSession)
((DeltaSession) contextSession).setPrimarySession(true);
}
}
}
}
use of org.apache.catalina.ha.session.DeltaSession in project tomcat70 by apache.
the class ReplicationValve method sendCrossContextSession.
/**
* Send all changed cross context sessions to backups
* @param containerCluster
*/
protected void sendCrossContextSession(CatalinaCluster containerCluster) {
List<DeltaSession> sessions = crossContextSessions.get();
if (sessions != null && sessions.size() > 0) {
for (Iterator<DeltaSession> iter = sessions.iterator(); iter.hasNext(); ) {
Session session = iter.next();
if (log.isDebugEnabled())
log.debug(sm.getString("ReplicationValve.crossContext.sendDelta", session.getManager().getContainer().getName()));
sendMessage(session, (ClusterManager) session.getManager(), containerCluster);
if (doStatistics()) {
nrOfCrossContextSendRequests++;
}
}
}
}
use of org.apache.catalina.ha.session.DeltaSession in project tomcat by apache.
the class ReplicationValve method resetReplicationRequest.
/**
* Fix memory leak for long sessions with many changes, when no backup member exists!
* @param request current request after response is generated
* @param isCrossContext check crosscontext threadlocal
*/
protected void resetReplicationRequest(Request request, boolean isCrossContext) {
Session contextSession = request.getSessionInternal(false);
if (contextSession instanceof DeltaSession) {
resetDeltaRequest(contextSession);
((DeltaSession) contextSession).setPrimarySession(true);
}
if (isCrossContext) {
List<DeltaSession> sessions = crossContextSessions.get();
if (sessions != null && sessions.size() > 0) {
Iterator<DeltaSession> iter = sessions.iterator();
for (; iter.hasNext(); ) {
Session session = iter.next();
resetDeltaRequest(session);
if (session instanceof DeltaSession) {
((DeltaSession) contextSession).setPrimarySession(true);
}
}
}
}
}
use of org.apache.catalina.ha.session.DeltaSession in project tomcat by apache.
the class ReplicationValve method sendCrossContextSession.
/**
* Send all changed cross context sessions to backups
*/
protected void sendCrossContextSession() {
List<DeltaSession> sessions = crossContextSessions.get();
if (sessions != null && sessions.size() > 0) {
for (Iterator<DeltaSession> iter = sessions.iterator(); iter.hasNext(); ) {
Session session = iter.next();
if (log.isDebugEnabled()) {
log.debug(sm.getString("ReplicationValve.crossContext.sendDelta", session.getManager().getContext().getName()));
}
sendMessage(session, (ClusterManager) session.getManager());
if (doStatistics()) {
nrOfCrossContextSendRequests++;
}
}
}
}
use of org.apache.catalina.ha.session.DeltaSession 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