Tomcat 5.5 Cluster: Session Replication before sending the response
Hi everybody, I have a Tomcat 5.5 cluster with 2 nodes on SLES8 and want to replicate the complete session before the response is send. According to the Tomcat Clustering documentation the example with the DeltaManager does this since the ReplicationValve triggers the replication after the request has been processed and before the response is sent. Unfortunately the DeltaManager only replicates the changed data. Only changes made by using methods like setAttribute make changes visible to the DeltaManager and changes made to the object (like changing one field value noch setAttribute-call) do not. Thus I would need to change the way these objects are handled in the application. So I thought it would be the easiest way to just replicate the complete session instead of changes only. Is this possible? JavaDoc of org.apache.catalina.session.StandardManager: "Standard implementation of the Manager interface that provides simple session persistence across restarts of this component (such as when the entire server is shut down and restarted, or when a particular web application is reloaded." This sounds like the session is only replicated when the server ist shutdown/restarted/app reloaded. It also doesn't specify what is replicated - the complete session? Any suggestions? Thanks in advance --Andy - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: Tomcat 5.5 Cluster: Session Replication before sending the response
Hi Filip, Thanks for your answer. I also thought about this solution of just setting all objects again at the end of the doGet method. But if possible I would like to use a tomcat replication mechanism since I do not want to "manage" session since I have a tomcat-built-in session manager :) Andy -Ursprüngliche Nachricht- Von: Filip Hanik - Dev Lists [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 10. Januar 2007 16:52 An: Tomcat Users List Betreff: Re: Tomcat 5.5 Cluster: Session Replication before sending the response to achieve what you want, although slower, you can create a filter, and in that filter simply set all the attributes again Enumeration e = session.getAttributeNames(); while ( e.hasNext() ) { String name = e.next(); Object value = session.getAttribute(name); if ( value != null ) session.setAttribute(name,value); } you get the point :) Filip [EMAIL PROTECTED] wrote: > Hi everybody, > > I have a Tomcat 5.5 cluster with 2 nodes on SLES8 and want to replicate the > complete session before the response is send. According to the Tomcat > Clustering documentation the example with the DeltaManager does this since > the ReplicationValve triggers the replication after the request has been > processed and before the response is sent. > > Unfortunately the DeltaManager only replicates the changed data. Only changes > made by using methods like setAttribute make changes visible to the > DeltaManager and changes made to the object (like changing one field value > noch setAttribute-call) do not. > Thus I would need to change the way these objects are handled in the > application. So I thought it would be the easiest way to just replicate the > complete session instead of changes only. Is this possible? > > JavaDoc of org.apache.catalina.session.StandardManager: > "Standard implementation of the Manager interface that provides simple > session persistence across restarts of this component (such as when the > entire server is shut down and restarted, or when a particular web > application is reloaded." > > This sounds like the session is only replicated when the server ist > shutdown/restarted/app reloaded. It also doesn't specify what is replicated - > the complete session? > > Any suggestions? > > Thanks in advance > --Andy > > > > - > To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, > e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: AW: Tomcat 5.5 Cluster: Session Replication before sending the response
Hi Filip, I understand that I will just change the session in a way the delta manager will replicate everything. But is there no other Manager I can use which just replicates the complete session and not just the changed data (like the DeltaManager does)?! I couldn't find a Manager which replicates everything. Is there one? Thanks in advance! Andy -Ursprüngliche Nachricht- Von: Filip Hanik - Dev Lists [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 16. Januar 2007 15:35 An: Tomcat Users List Betreff: Re: AW: Tomcat 5.5 Cluster: Session Replication before sending the response even with this method, you are not managing the sessions, you're just making sure that everything gets replicated, so doing this, you are not changing the session manager. remember, the code below would be inserted into a filter or a valve Filip wrote: > Hi Filip, > > Thanks for your answer. I also thought about this solution of just setting > all objects again at the end of the doGet method. > But if possible I would like to use a tomcat replication mechanism > since I do not want to "manage" session since I have a tomcat-built-in > session manager :) > > Andy > > -Ursprüngliche Nachricht- > Von: Filip Hanik - Dev Lists [mailto:[EMAIL PROTECTED] > Gesendet: Mittwoch, 10. Januar 2007 16:52 > An: Tomcat Users List > Betreff: Re: Tomcat 5.5 Cluster: Session Replication before sending > the response > > to achieve what you want, although slower, you can create a filter, > and in that filter simply set all the attributes again > > Enumeration e = session.getAttributeNames(); while ( e.hasNext() ) { > String name = e.next(); > Object value = session.getAttribute(name); > if ( value != null ) session.setAttribute(name,value); } > > you get the point :) > > Filip > > wrote: > >> Hi everybody, >> >> I have a Tomcat 5.5 cluster with 2 nodes on SLES8 and want to replicate the >> complete session before the response is send. According to the Tomcat >> Clustering documentation the example with the DeltaManager does this since >> the ReplicationValve triggers the replication after the request has been >> processed and before the response is sent. >> >> Unfortunately the DeltaManager only replicates the changed data. Only >> changes made by using methods like setAttribute make changes visible to the >> DeltaManager and changes made to the object (like changing one field value >> noch setAttribute-call) do not. >> Thus I would need to change the way these objects are handled in the >> application. So I thought it would be the easiest way to just replicate the >> complete session instead of changes only. Is this possible? >> >> JavaDoc of org.apache.catalina.session.StandardManager: >> "Standard implementation of the Manager interface that provides simple >> session persistence across restarts of this component (such as when the >> entire server is shut down and restarted, or when a particular web >> application is reloaded." >> >> This sounds like the session is only replicated when the server ist >> shutdown/restarted/app reloaded. It also doesn't specify what is replicated >> - the complete session? >> >> Any suggestions? >> >> Thanks in advance >> --Andy - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: AW: AW: Tomcat 5.5 Cluster: Session Replication before sending the response
Hi Peter, Thanks for your answer. As far as I know the SimpleTcpReplicationManager has been implemented for Tomcat 4 an replicates the session when it changes. So everytime the session changes it would replicate it. Thus TC would replicate my session several times during the processing of a request which would not be appropriate since the session would hold the wrong information in case tomcat crashes during the processing of a request but already replicated the session several times. Thus it really looks like the only way to replicate the complete session is to implement a filter or valve. Regards Andy -Ursprüngliche Nachricht- Von: Peter Rossbach [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 17. Januar 2007 09:43 An: Tomcat Users List Betreff: Re: AW: AW: Tomcat 5.5 Cluster: Session Replication before sending the response Hi you can give o.a.c.cluster.session.SimpleTcpReplicationManager a chance, but I don't know it works really. Regards Peter Am 16.01.2007 um 15:57 schrieb <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>: > Hi Filip, > > I understand that I will just change the session in a way the delta > manager will replicate everything. > But is there no other Manager I can use which just replicates the > complete session and not just the changed data (like the DeltaManager > does)?! > > I couldn't find a Manager which replicates everything. Is there one? > > Thanks in advance! > > Andy > > > -Ursprüngliche Nachricht- > Von: Filip Hanik - Dev Lists [mailto:[EMAIL PROTECTED] > Gesendet: Dienstag, 16. Januar 2007 15:35 > An: Tomcat Users List > Betreff: Re: AW: Tomcat 5.5 Cluster: Session Replication before > sending the response > > even with this method, you are not managing the sessions, you're just > making sure that everything gets replicated, so doing this, you are > not changing the session manager. > remember, the code below would be inserted into a filter or a valve > > Filip > > wrote: >> Hi Filip, >> >> Thanks for your answer. I also thought about this solution of just >> setting all objects again at the end of the doGet method. >> But if possible I would like to use a tomcat replication mechanism >> since I do not want to "manage" session since I have a tomcat- >> built-in session manager :) >> >> Andy >> >> -Ursprüngliche Nachricht- >> Von: Filip Hanik - Dev Lists [mailto:[EMAIL PROTECTED] >> Gesendet: Mittwoch, 10. Januar 2007 16:52 >> An: Tomcat Users List >> Betreff: Re: Tomcat 5.5 Cluster: Session Replication before sending >> the response >> >> to achieve what you want, although slower, you can create a filter, >> and in that filter simply set all the attributes again >> >> Enumeration e = session.getAttributeNames(); while ( e.hasNext() ) { >> String name = e.next(); >> Object value = session.getAttribute(name); >> if ( value != null ) session.setAttribute(name,value); } >> >> you get the point :) >> >> Filip >> >> wrote: >> >>> Hi everybody, >>> >>> I have a Tomcat 5.5 cluster with 2 nodes on SLES8 and want to >>> replicate the complete session before the response is send. >>> According to the Tomcat Clustering documentation the example with >>> the DeltaManager does this since the ReplicationValve triggers the >>> replication after the request has been processed and before the >>> response is sent. >>> >>> Unfortunately the DeltaManager only replicates the changed data. >>> Only changes made by using methods like setAttribute make changes >>> visible to the DeltaManager and changes made to the object (like >>> changing one field value noch setAttribute-call) do not. >>> Thus I would need to change the way these objects are handled in the >>> application. So I thought it would be the easiest way to just >>> replicate the complete session instead of changes only. Is this >>> possible? >>> >>> JavaDoc of org.apache.catalina.session.StandardManager: >>> "Standard implementation of the Manager interface that provides >>> simple session persistence across restarts of this component (such >>> as when the entire server is shut down and restarted, or when a >>> particular web application is reloaded." >>> >>> This sounds like the session is only replicated when the server ist >>> shutdown/restarted/app reloaded. It also doesn't specify what is >>> replicated - the complete session? >>> >>> Any suggestions? >>> >>> Thanks in advance >>> --Andy > > > - > To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, > e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > - > To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, > e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To start a new topic, e-mail: users@tomcat.apache.org To
AW: AW: AW: AW: Tomcat 5.5 Cluster: Session Replication before sending the response
Hi Peter, The ReplicationValve will intercept the request when the request is completed and before the response is returned to the user. Copied from the JavaDoc for the SimpleTcpReplicationManager: Title: Tomcat Session Replication for Tomcat 4.0 Description: A very simple straight forward implementation of session replication of servers in a cluster. This session replication is implemented "live". By live I mean, when a session attribute is added into a session on Node A a message is broadcasted to other messages and setAttribute is called on the replicated sessions. A full description of this implementation can be found under Filip's Tomcat Page Copyright: See apache license Company: www.filip.net (Tomcat Site is not available). This sounds like it works just like the DeltaManager replicating the changes not the complete session. My applikations works on the objects written to the session but does not call setAttribute again and so neither the DeltaManager nor the SimpleTcpReplicationManager would replicate these objects. Thus I am looking for a Manager which just replicates the complete session (after processing the request) no matter what. To trigger the replication the ReplicationValve is used but I am still searching for a *Manager which fits my needs described above. Regards Andy -Ursprüngliche Nachricht- Von: Peter Rossbach [mailto:[EMAIL PROTECTED] Gesendet: Donnerstag, 18. Januar 2007 08:45 An: Tomcat Users List Betreff: Re: AW: AW: AW: Tomcat 5.5 Cluster: Session Replication before sending the response Hmm, It is not true, that multiple session replications are processed of one request! Session are replicated only after response processing is finished, see class o.a.c.cluster.tcp.ReplicationValve. As you have multiple request at same session, you can have small inconsistency problems. Regards Peter Am 17.01.2007 um 10:38 schrieb <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>: > Hi Peter, > > Thanks for your answer. As far as I know the > SimpleTcpReplicationManager has been implemented for Tomcat 4 an > replicates the session when it changes. So everytime the session > changes it would replicate it. Thus TC would replicate my session > several times during the processing of a request which would not be > appropriate since the session would hold the wrong information in > case tomcat crashes during the processing of a request but already > replicated the session several times. Thus it really looks like the > only way to replicate the complete session is to implement a filter > or valve. > > Regards > Andy > > -Ursprüngliche Nachricht- > Von: Peter Rossbach [mailto:[EMAIL PROTECTED] > Gesendet: Mittwoch, 17. Januar 2007 09:43 > An: Tomcat Users List > Betreff: Re: AW: AW: Tomcat 5.5 Cluster: Session Replication before > sending the response > > Hi > > you can give o.a.c.cluster.session.SimpleTcpReplicationManager a > chance, but I don't know it works really. > > Regards > Peter > > > Am 16.01.2007 um 15:57 schrieb <[EMAIL PROTECTED]> > <[EMAIL PROTECTED]>: > >> Hi Filip, >> >> I understand that I will just change the session in a way the delta >> manager will replicate everything. >> But is there no other Manager I can use which just replicates the >> complete session and not just the changed data (like the DeltaManager >> does)?! >> >> I couldn't find a Manager which replicates everything. Is there one? >> >> Thanks in advance! >> >> Andy >> >> >> -Ursprüngliche Nachricht- >> Von: Filip Hanik - Dev Lists [mailto:[EMAIL PROTECTED] >> Gesendet: Dienstag, 16. Januar 2007 15:35 >> An: Tomcat Users List >> Betreff: Re: AW: Tomcat 5.5 Cluster: Session Replication before >> sending the response >> >> even with this method, you are not managing the sessions, you're just >> making sure that everything gets replicated, so doing this, you are >> not changing the session manager. >> remember, the code below would be inserted into a filter or a valve >> >> Filip >> >> wrote: >>> Hi Filip, >>> >>> Thanks for your answer. I also thought about this solution of just >>> setting all objects again at the end of the doGet method. >>> But if possible I would like to use a tomcat replication mechanism >>> since I do not want to "manage" session since I have a tomcat- >>> built-in session manager :) >>> >>> Andy >>> >>> -Ursprüngliche Nachricht- >>> Von: Filip Hanik - Dev Lists [mailto:[EMAIL PROTECTED] >>> Gesendet: Mittwoch, 10. Januar 2007 16:52 >>> An: Tomcat Users List >>> Betreff: Re: Tomcat 5.5 Cluster: Session Replication before sending >>> the response >>> >>> to achieve what you want, although slower, you can create a filter, >>> and in that filter simply set all the attributes again >>> >>> Enumeration e = session.getAttributeNames(); while ( e.hasNext() ) { >>> String name = e.next(); >>> Object value = session.getAttribute(name); >>> if ( value != null ) session.setAttribute(name,value); } >>> >>> you get the point :) >>>
AW: AW: AW: AW: AW: Tomcat 5.5 Cluster: Session Replication before sending the response
Hi Peter, Thanks for your very detailed answer. I see, ReplicationValve triggers the session replication after completion of request/response. But which data of the session (parts or the complete session) depends on the manager. Looking at the JavaDoc neither DeltaManager nor StandardManager nor SimpleTcpReplicationManger replicate the complete Session. Thus I am still lokking for a manager that replicates the complete session. The mentioned Managers just replicate the data added removed or changed using setAttribute. So the objects in my session which are changed but not reset using setAttribute will not be replicated. That is my problem and as far as I understand it still is. I will give the logging a try to see what is replicated but looking at the documentation my problem is not soled :-( Regards Andy -Ursprüngliche Nachricht- Von: Peter Rossbach [mailto:[EMAIL PROTECTED] Gesendet: Donnerstag, 18. Januar 2007 13:49 An: Tomcat Users List Betreff: Re: AW: AW: AW: AW: Tomcat 5.5 Cluster: Session Replication before sending the response Hi Andy, Please, look to ReplicationValve source code! === Snip ReplicationValve code 346ff getNext().invoke(request, response); Manager manager = request.getContext().getManager(); if (manager != null && manager instanceof ClusterManager) { ClusterManager clusterManager = (ClusterManager) manager; CatalinaCluster containerCluster = (CatalinaCluster) getContainer().getCluster(); if (containerCluster == null) { if (log.isWarnEnabled()) log.warn(sm.getString ("ReplicationValve.nocluster")); return; } // valve cluster can access manager - other cluster handle replication // at host level - hopefully! if(containerCluster.getManager(clusterManager.getName ()) == null) return ; if(containerCluster.hasMembers()) { sendReplicationMessage(request, totalstart, isCrossContext, clusterManager, containerCluster); } else { resetReplicationRequest(request,isCrossContext); } === You see that first complete request/response is process and after that the replication message is generated and send. Both cluster session manager send the delta or complete session after response is complete processed. OK, the description is bad, but the code is clean :-) Please setup a cluster with clusterlog: ... and setup conf/logging.properties #handlers = java.util.logging.ConsoleHandler handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler .handlers = java.util.logging.ConsoleHandler #.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler # Handler specific properties. # Describes specific configuration info for Handlers. 1catalina.org.apache.juli.FileHandler.level = FINE 1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs 1catalina.org.apache.juli.FileHandler.prefix = clusterLog. java.util.logging.ConsoleHandler.level = FINE java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter # Facility specific properties. # Provides extra control for each logger. org.apache.catalina.core.ContainerBase.[Catalina].level = INFO #org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO #org.apache.catalina.core.ContainerBase.[Catalina]. [localhost].handlers = 2localhost.org.apache.juli.FileHandler # For example, set the com.xyz.foo logger to only log SEVERE # messages: #org.apache.catalina.startup.ContextConfig.level = FINE #org.apache.catalina.startup.HostConfig.level = FINE #org.apache.catalina.session.ManagerBase.level = FINE org.apache.catalina.cluster.tcp.ReplicationValve.level = FINE clusterLog.handlers= 1catalina.org.apache.juli.FileHandler clusterLog.level=INFO === With this configuration you get a protocol from every message that cluster send or received. Regards Peter Am 18.01.2007 um 10:31 schrieb <[EMAIL PROTECTED]>: > Hi Peter, > > The ReplicationValve will intercept the request when the request is > completed and before the response is returned to the user. > > Copied from the JavaDoc for the SimpleTcpReplicationManager: > Title: Tomcat Session Replication for Tomcat 4.0 > Description: A very simple straight forward implementation of session > replication of servers in a cluster. > This session replication is implemented "live". By live I mean, when a > session attribute is added into a session on Node A a message is > broadcasted to other messages a
AW: AW: AW: AW: AW: AW: Tomcat 5.5 Cluster: Session Replication before sending the response
Hi Rainer, Thanks for your help. To me it sounds like Filip's solution using a servlet filter or another valve and set all session attributes again in combination with the deltaManager is the best solution at the moment looking at the cost-value ratio. Regards, ---Andy -Ursprüngliche Nachricht- Von: Rainer Jung [mailto:[EMAIL PROTECTED] Gesendet: Donnerstag, 18. Januar 2007 17:01 An: Tomcat Users List Betreff: Re: AW: AW: AW: AW: AW: Tomcat 5.5 Cluster: Session Replication before sending the response [EMAIL PROTECTED] wrote: > Hi Peter, > > Thanks for your very detailed answer. > > I see, ReplicationValve triggers the session replication after completion of > request/response. But which data of the session (parts or the complete > session) depends on the manager. Looking at the JavaDoc neither DeltaManager > nor StandardManager nor SimpleTcpReplicationManger replicate the complete > Session. Thus I am still lokking for a manager that replicates the complete > session. The mentioned Managers just replicate the data added removed or > changed using setAttribute. So the objects in my session which are changed > but not reset using setAttribute will not be replicated. That is my problem > and as far as I understand it still is. The Manager implementation SimpleTcpReplicationManager sends the complete session during its requestCompleted() method (called by the Valve) - if it sends it at all. To decide if it needs to send it, it can use two principles: - with useDirtyFlag="false" it will always be send (on every request!) - with useDirtyFlag="true" it will only be send, if the session is new, or request attributes have been added or changed via setAttribute etc. Hope that helps. Caution: I expect that SimpleTcpReplicationManager has rarely been used in the last two years because of it's severe performance implications. It could be, that the DeltaManager has bugs fixed, which are still unfixed in SimpleTcpReplicationManager. Regards, Rainer > > I will give the logging a try to see what is replicated but looking at > the documentation my problem is not soled :-( > > Regards > Andy > - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]