Okay,

I have created a small patch that seems to fix my problems. It can be
downloaded at
http://cedarsoft.de/tmp/terracotta_compatibility_patch.patch

I am not sure whether that is enough for terracotta support, but for me
it works so far.
And I don't understand whether I have added a pitfall to Joda time.

The problem is that 
org.joda.time.base.AbstractPartial#compareTo
compares the field types using "!=" but when using a cluster those
instances are not identical.
So I have added a simple "equals" method to
org.joda.time.DateTimeFieldType.StandardDateTimeFieldType.


At the moment I use that patched version successfully. It would be great
if anyone could take a look at that patch and give some comments whether
that is a valid change that could be added to the trunk.


Regards,

Johannes Schneider


On Wed, 2008-03-26 at 19:35 +0100, Johannes Schneider wrote:
> I forced Terracotta to share all static fields within
> org.joda.time.DateTimeFieldType.
> Without that the methods "isAfter", "isBefore" etc. fail with that
> exception:
> 
>  Exception in thread "Thread-12" java.lang.ClassCastException:
> ReadablePartial objects must have matching field types
> [INFO] [client]         at
> org.joda.time.base.AbstractPartial.compareTo(AbstractPartial.java:325)
> [INFO] [client]         at
> org.joda.time.LocalDate.compareTo(LocalDate.java:566)
> [INFO] [client]         at
> org.joda.time.base.AbstractPartial.isBefore(AbstractPartial.java:381)
> 
> 
> The problem is that the DateTimeFields are cached using static fields
> within DateTimeFieldType.
> While Terracotta is able to transfer the DateTime object to the other
> JVM, the static fields are different on each of those VMs.
> So comparisons using "==" fail....
> 
> So maybe that could/should be fixed? Do you have an idea how that could
> be achieved?
> 
> 
> Regards,
> 
> Johannes Schneider
> 
> On Wed, 2008-03-26 at 08:41 -0700, Brian S O'Neill wrote:
> > It looks like Terracotta is sharing things that aren't intended to be 
> > shared. The time zone cache is just a performance optimization for the 
> > local JVM. How can you instruct Terracotta not to share this? I have no 
> > experience with Terracotta.
> > 
> > The only amount of sharing which was anticipated was serialization of 
> > the top-level objects, like DateTime. These objects serialize the 
> > minimum amount of data and no runtime state. Put another way, Joda-Time 
> > deals with small data objects, and only data is intended to be shared. 
> > Is Terracotta trying to share the entire Joda-Time runtime? This does 
> > not make sense.
> > 
> > Johannes Schneider wrote:
> > > Hi,
> > >
> > > I run into big performance problems regarding Joda and Terracotta (a
> > > clustering solution).
> > > At the moment I don't have any ideas how to solve that. Maybe anybody
> > > has any experiences with Joda and Terracotta?
> > >
> > > I have created a small micro benchmark to test that. It can be found at
> > > the Terracotta forums
> > > (http://forums.terracotta.org/forums/posts/list/0/903.page#5537).
> > >
> > > The main problem is that it seems to be necessary to add the following
> > > fields as root:
> > >
> > >       <roots>
> > >         <root>
> > >           <field-expression>private static final
> > > org.joda.time.DateTimeFieldType
> > > org.joda.time.DateTimeFieldType.*</field-expression>
> > >         </root>
> > >       </roots>
> > >
> > > If I don't add that root the methods #isAfter() #isBefore #isEquals
> > > don't work as expected.
> > >
> > > And therefore it is necessary to add locking for those methods:
> > >
> > >         <autolock auto-synchronized="true">
> > >           <method-expression>*
> > > org.joda.time.tz.CachedDateTimeZone.get*(..)</method-expression>
> > >           <lock-level>write</lock-level>
> > >         </autolock>
> > >         <autolock auto-synchronized="true">
> > >           <method-expression>*
> > > org.joda.time.chrono.BasicChronology.get*(..)</method-expression>
> > >           <lock-level>write</lock-level>
> > >         </autolock>
> > >
> > >
> > > But locking those methods on the hole cluster results in a major
> > > performance impact when working with Joda objects.
> > >
> > > If anyone can give me any hint or comment, that will be great. At the
> > > moment I am thinking about removing Joda Time completely from the
> > > cluster and only do local calculations with Joda. But that means a lot
> > > of work and I really don't wanna miss Joda time...
> > >
> > >
> > >
> > > Regards,
> > >
> > > Johannes Schneider
> > >
> > >   
> > > ------------------------------------------------------------------------
> > >
> > > -------------------------------------------------------------------------
> > > Check out the new SourceForge.net Marketplace.
> > > It's the best place to buy or sell services for
> > > just about anything Open Source.
> > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> > > ------------------------------------------------------------------------
> > >
> > > _______________________________________________
> > > Joda-interest mailing list
> > > Joda-interest@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/joda-interest
> > >   
> > 
> > -------------------------------------------------------------------------
> > Check out the new SourceForge.net Marketplace.
> > It's the best place to buy or sell services for
> > just about anything Open Source.
> > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> > _______________________________________________
> > Joda-interest mailing list
> > Joda-interest@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/joda-interest
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> _______________________________________________ Joda-interest mailing list 
> Joda-interest@lists.sourceforge.net 
> https://lists.sourceforge.net/lists/listinfo/joda-interest
-- 
Johannes Schneider
Im Lindenwasen 15
72810 Gomaringen

Fon +49 7072 9229972
Fax +49 7072 509999
Mobil +49 178 1364488

[EMAIL PROTECTED]
http://www.johannes-schneider.info

Attachment: smime.p7s
Description: S/MIME cryptographic signature

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to