You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Carrillo, Dan" <dc...@idanalytics.com> on 2012/09/19 17:58:42 UTC

sessions replication

Hi folks,
My sessions are replicating across the cluster as indicated by my session listener debug output.  E.g I can see the session created/destroyed messages in each respective log.
I have a Service object that is serializable, which contains a String member variable (x) which is not initialized; null.  As my load balancer round-robins the requests to each of these servers, each successfully retrieves the service instance from the session.  Now, when service.x is set at some point in the workflow, I expect the other members to receive this updated object since it resides in the session.  However, I'm finding that it is not, it remains null in all other containers.

The tomcat config (http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html) says that "..For each request the entire session is replicated, this allows code that modifies attributes in the session without calling setAttribute or removeAttribute to be replicated."

Can someone clarify whether I do in fact need to reset the service object on the session in order for it to replicate?

Thanks!

<Engine name="Catalina" defaultHost="localhost" jvmRoute="id2">
        <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
                 channelSendOptions="6">

          <Manager className="org.apache.catalina.ha.session.DeltaManager"
                   expireSessionsOnShutdown="false"
                   notifyListenersOnReplication="true"/>

          <Channel className="org.apache.catalina.tribes.group.GroupChannel">
          <Membership className="org.apache.catalina.tribes.membership.McastService"
                   address="231.10.12.6"
                   port="35006"
                   frequency="500"
                   dropTime="3000"/>
          <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
                   address="auto"
                   port="8117"
                   selectorTimeout="100"
                   maxThreads="6"/>

            <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
              <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
            </Sender>
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>
          </Channel>

          <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
                 filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>
          <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
        </Cluster>

Re: sessions replication

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Pid,

On 9/19/12 2:08 PM, Pid * wrote:
> On 19 Sep 2012, at 16:59, "Carrillo, Dan"
> <dc...@idanalytics.com> wrote:
> 
>> Hi folks, My sessions are replicating across the cluster as
>> indicated by my session listener debug output.  E.g I can see the
>> session created/destroyed messages in each respective log. I have
>> a Service object that is serializable, which contains a String
>> member variable (x) which is not initialized; null.  As my load
>> balancer round-robins the requests to each of these servers, each
>> successfully retrieves the service instance from the session.
>> Now, when service.x is set at some point in the workflow, I
>> expect the other members to receive this updated object since it
>> resides in the session.  However, I'm finding that it is not, it
>> remains null in all other containers.
>> 
>> The tomcat config
>> (http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html) says
>> that "..For each request the entire session is replicated, this
>> allows code that modifies attributes in the session without
>> calling setAttribute or removeAttribute to be replicated."
>> 
>> Can someone clarify whether I do in fact need to reset the
>> service object on the session in order for it to replicate?
> 
> If by this, you are asking whether you can retrieve an object from
> the session, update it and without adding it back to the session
> expect these changes to be propagated, then no, you can't.

That note in the official documentation certainly is misleading. I
believe that the session is is only marked "dirty" if one of
HttpSession.setAttribute or HttpSession.removeAttribute is invoked. I
think the statement in question indicates that, if the HttpSession is
to be replicated, it will be replicated in full and not piecemeal.

But you still have to call HttpSession.setAttribute in order to
trigger the replication in the first place.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlBaIzIACgkQ9CaO5/Lv0PC+MgCeOymBWWhOx5lDtBBAN79VSbDB
UK8An3O5/EBUYM7D1Biy8z0CenAhKzHB
=m6N6
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: sessions replication

Posted by Pid * <pi...@pidster.com>.
On 19 Sep 2012, at 16:59, "Carrillo, Dan" <dc...@idanalytics.com> wrote:

> Hi folks,
> My sessions are replicating across the cluster as indicated by my session listener debug output.  E.g I can see the session created/destroyed messages in each respective log.
> I have a Service object that is serializable, which contains a String member variable (x) which is not initialized; null.  As my load balancer round-robins the requests to each of these servers, each successfully retrieves the service instance from the session.  Now, when service.x is set at some point in the workflow, I expect the other members to receive this updated object since it resides in the session.  However, I'm finding that it is not, it remains null in all other containers.
>
> The tomcat config (http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html) says that "..For each request the entire session is replicated, this allows code that modifies attributes in the session without calling setAttribute or removeAttribute to be replicated."
>
> Can someone clarify whether I do in fact need to reset the service object on the session in order for it to replicate?

If by this, you are asking whether you can retrieve an object from the
session, update it and without adding it back to the session expect
these changes to be propagated, then no, you can't.


p


>
> Thanks!
>
> <Engine name="Catalina" defaultHost="localhost" jvmRoute="id2">
>        <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
>                 channelSendOptions="6">
>
>          <Manager className="org.apache.catalina.ha.session.DeltaManager"
>                   expireSessionsOnShutdown="false"
>                   notifyListenersOnReplication="true"/>
>
>          <Channel className="org.apache.catalina.tribes.group.GroupChannel">
>          <Membership className="org.apache.catalina.tribes.membership.McastService"
>                   address="231.10.12.6"
>                   port="35006"
>                   frequency="500"
>                   dropTime="3000"/>
>          <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
>                   address="auto"
>                   port="8117"
>                   selectorTimeout="100"
>                   maxThreads="6"/>
>
>            <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
>              <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
>            </Sender>
>            <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
>            <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
>            <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>
>          </Channel>
>
>          <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
>                 filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>
>          <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
>        </Cluster>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org