tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <knst.koli...@gmail.com>
Subject Re: Distributable contexts and non-serializable session attributes
Date Mon, 11 Jul 2011 11:41:02 GMT
2011/7/10 Rainer Jung <rainer.jung@kippdata.de>:
> I implemented an addition to DeltaManager which allows to filter which
> session attributes actually get replicated (not yet committed).
>
> This is useful, because many applications
>
> - use non-serializable session attributes, so
>  it is not possible to simply replicate everything
>
> - do not actually need everything replicated, because they
>  can bootstrap all they need from a login context if a filter
>  detects, that a failover has happened.
>
> In these cases it can also help to reduce replication traffic a lot.
>
> Unfortunately I stu,bled into some code in StandardSession:
>
> public void setAttribute(String name, Object value, boolean notify) {
> ...
> if ((manager != null) && manager.getDistributable() &&
>  !(value instanceof Serializable))
>    throw new IllegalArgumentException
>        (sm.getString("standardSession.setAttribute.iae", name));
> ...
> }
>
> This means if you enable "distributable", then you can no longer set any
> non-serializable session attribute. The code is not recent, it goes back
> to at least TC 3.3.
>
> I understand, that it is helpful to devs being informed about
> serialization/replication problems. But I think it is too strict to
> enforce this in StandardSession whch is the base class of all our
> cluster sessions and we always delegate to
> StandardSession.setAttribute() after some cluster specific handling.
>
> The SPEC says:
>
> The container must accept objects that implement the Serializable interface.
> - The container may choose to support storage of other designated
> objects in the
> HttpSession, such as references to Enterprise JavaBeans components and
> transactions.
> - Migration of sessions will be handled by container-specific facilities.
> The distributed servlet container must throw an IllegalArgumentException for
> objects where the container cannot support the mechanism necessary for
> migration
> of the session storing them.
>
> (and some more in 7.7.2).
>
> I think checking for serializability in StandardSession isn't good,
> because AFAIK StandardSession isn't used by any mechanism Tomcat
> supports to implement "distributable".
>
> And in DeltaSession I would like to have the check optional, i.e. only
> check if the configuration wants the attribute to be replicated.
>
> By default all attributes will be replicated as is today, but by
> configuration one will be able to choose attributes to replicate using a
> regexp against the attribute name.
>
> Any remarks?
>

I think you are right and we can relax the requirement.
E.g. to delegate the check to some helper method that is overwritten
in DeltaSession or in other derived class.

Best regards,
Konstantin Kolinko

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


Mime
View raw message