org.apache.catalina.ha.session.DeltaSession Java Examples
The following examples show how to use
org.apache.catalina.ha.session.DeltaSession.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReplicationValve.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Send all changed cross context sessions to backups */ protected void sendCrossContextSession() { List<DeltaSession> sessions = crossContextSessions.get(); if(sessions != null && sessions.size() >0) { for (DeltaSession session : sessions) { if(log.isDebugEnabled()) { log.debug(sm.getString("ReplicationValve.crossContext.sendDelta", session.getManager().getContext().getName() )); } sendMessage(session,(ClusterManager)session.getManager()); if(doStatistics()) { nrOfCrossContextSendRequests++; } } } }
Example #2
Source File: ReplicationValve.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * 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); } } } } }
Example #3
Source File: ReplicationValve.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * 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++; } } } }
Example #4
Source File: ReplicationValve.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * 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); } } } }
Example #5
Source File: ReplicationValve.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * 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++; } } } }
Example #6
Source File: ReplicationValve.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * 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); } } } }
Example #7
Source File: ReplicationValve.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * 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. * * @param session cross context session */ public void registerReplicationSession(DeltaSession session) { List<DeltaSession> sessions = crossContextSessions.get(); if(sessions != null) { if(!sessions.contains(session)) { if(log.isDebugEnabled()) { log.debug(sm.getString("ReplicationValve.crossContext.registerSession", session.getIdInternal(), session.getManager().getContext().getName())); } sessions.add(session); } } }
Example #8
Source File: ReplicationValve.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Reset DeltaRequest from session * @param session HttpSession from current request or cross context session */ protected void resetDeltaRequest(Session session) { if(log.isDebugEnabled()) { log.debug(sm.getString("ReplicationValve.resetDeltaRequest" , session.getManager().getContext().getName() )); } ((DeltaSession)session).resetDeltaRequest(); }
Example #9
Source File: ReplicationValve.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * 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. * * @param session cross context session */ public void registerReplicationSession(DeltaSession session) { List<DeltaSession> sessions = crossContextSessions.get(); if(sessions != null) { if(!sessions.contains(session)) { if(log.isDebugEnabled()) log.debug(sm.getString("ReplicationValve.crossContext.registerSession", session.getIdInternal(), session.getManager().getContainer().getName())); sessions.add(session); } } }
Example #10
Source File: ReplicationValve.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Reset DeltaRequest from session * @param session HttpSession from current request or cross context session */ protected void resetDeltaRequest(Session session) { if(log.isDebugEnabled()) { log.debug(sm.getString("ReplicationValve.resetDeltaRequest" , session.getManager().getContainer().getName() )); } ((DeltaSession)session).resetDeltaRequest(); }
Example #11
Source File: ReplicationValve.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * 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. * * @param session cross context session */ public void registerReplicationSession(DeltaSession session) { List<DeltaSession> sessions = crossContextSessions.get(); if(sessions != null) { if(!sessions.contains(session)) { if(log.isDebugEnabled()) log.debug(sm.getString("ReplicationValve.crossContext.registerSession", session.getIdInternal(), session.getManager().getContainer().getName())); sessions.add(session); } } }
Example #12
Source File: ReplicationValve.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Reset DeltaRequest from session * @param session HttpSession from current request or cross context session */ protected void resetDeltaRequest(Session session) { if(log.isDebugEnabled()) { log.debug(sm.getString("ReplicationValve.resetDeltaRequest" , session.getManager().getContainer().getName() )); } ((DeltaSession)session).resetDeltaRequest(); }
Example #13
Source File: ReplicationValve.java From Tomcat8-Source-Read with MIT License | 4 votes |
/** * 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(); // valve cluster can access manager - other cluster handle replication // at host level - hopefully! if(cluster.getManager(clusterManager.getName()) == null) { return ; } if(cluster.hasMembers()) { sendReplicationMessage(request, totalstart, isCrossContext, clusterManager); } else { resetReplicationRequest(request,isCrossContext); } } } finally { // Array must be remove: Current master request send endAccess at recycle. // 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); } } }
Example #14
Source File: ReplicationValve.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
/** * 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(); // valve cluster can access manager - other cluster handle replication // 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 { // Array must be remove: Current master request send endAccess at recycle. // 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); } } }
Example #15
Source File: ReplicationValve.java From tomcatsrc with Apache License 2.0 | 4 votes |
/** * 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(); // valve cluster can access manager - other cluster handle replication // 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 { // Array must be remove: Current master request send endAccess at recycle. // 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); } } }