You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-dev@db.apache.org by Erik Bengtson <er...@jpox.org> on 2006/05/24 16:21:27 UTC
huge volumes and flush
Hi,
In case of huge amount of objects loaded /persisted, the flush method is for
this purpose. I wonder how the cache/state management can be implemented
without breaking JDO contract and capable to handle load, any tips?
Thanks
Erik Bengtson
Re: huge volumes and flush
Posted by Michael Bouschen <mb...@spree.de>.
Hi Erik,
most probably you know already: class WeakHashMap from java.util does
not help when implementing the map of flushed instances. The WeakHashMap
uses a WeakReference for the key, but it strongly references the value
which is the flushed instance in your case. You need a map
implementation that maintains a strong reference to the key, but a weak
reference to the value. Just in case you are interested: there is a
tested implementation in the core20 module of the apache jdo repository.
The class is called WeakValueHashMap and you find it under
core20/src/java/org/apache/jdo/util.
Regards Michael
> Thanks Craig,
>
> I works now.
>
> Quoting Craig L Russell <Cr...@Sun.COM>:
>
>
>> Hi Erik,
>>
>> Generally, use weak references to persistent instances so they can be
>> garbage collected when the user no longer holds a strong reference to
>> them. Unflushed dirty instances need to be referenced strongly so
>> they are not garbage collected. So at flush time, move the flushed
>> dirty instances from a strong-reference map to a weak-reference map
>> (key = oid, value = weak-reference object).
>>
>> Craig
>>
>> On May 24, 2006, at 7:21 AM, Erik Bengtson wrote:
>>
>>
>>> Hi,
>>>
>>> In case of huge amount of objects loaded /persisted, the flush
>>> method is for
>>> this purpose. I wonder how the cache/state management can be
>>> implemented
>>> without breaking JDO contract and capable to handle load, any tips?
>>>
>>> Thanks
>>>
>>> Erik Bengtson
>>>
>> Craig Russell
>> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
>> 408 276-5638 mailto:Craig.Russell@sun.com
>> P.S. A good JDO? O, Gasp!
>>
>>
>>
>
>
>
--
Michael Bouschen Tech@Spree Engineering GmbH
mailto:mbo.tech@spree.de http://www.tech.spree.de/
Tel.:++49/30/235 520-33 Buelowstr. 66
Fax.:++49/30/2175 2012 D-10783 Berlin
Re: huge volumes and flush
Posted by Erik Bengtson <er...@jpox.org>.
Thanks Craig,
I works now.
Quoting Craig L Russell <Cr...@Sun.COM>:
> Hi Erik,
>
> Generally, use weak references to persistent instances so they can be
> garbage collected when the user no longer holds a strong reference to
> them. Unflushed dirty instances need to be referenced strongly so
> they are not garbage collected. So at flush time, move the flushed
> dirty instances from a strong-reference map to a weak-reference map
> (key = oid, value = weak-reference object).
>
> Craig
>
> On May 24, 2006, at 7:21 AM, Erik Bengtson wrote:
>
> >
> >
> > Hi,
> >
> > In case of huge amount of objects loaded /persisted, the flush
> > method is for
> > this purpose. I wonder how the cache/state management can be
> > implemented
> > without breaking JDO contract and capable to handle load, any tips?
> >
> > Thanks
> >
> > Erik Bengtson
>
> Craig Russell
> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
> 408 276-5638 mailto:Craig.Russell@sun.com
> P.S. A good JDO? O, Gasp!
>
>
Re: huge volumes and flush
Posted by Craig L Russell <Cr...@Sun.COM>.
Hi Erik,
Generally, use weak references to persistent instances so they can be
garbage collected when the user no longer holds a strong reference to
them. Unflushed dirty instances need to be referenced strongly so
they are not garbage collected. So at flush time, move the flushed
dirty instances from a strong-reference map to a weak-reference map
(key = oid, value = weak-reference object).
Craig
On May 24, 2006, at 7:21 AM, Erik Bengtson wrote:
>
>
> Hi,
>
> In case of huge amount of objects loaded /persisted, the flush
> method is for
> this purpose. I wonder how the cache/state management can be
> implemented
> without breaking JDO contract and capable to handle load, any tips?
>
> Thanks
>
> Erik Bengtson
Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!