You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-dev@jakarta.apache.org by Christian Kreutzfeldt <ch...@gmx.de> on 2003/11/17 09:23:08 UTC

Re: AW: [indexeddiskcache] key file not written

On Thursday 13 November 2003 17:51, Vossberg, Michal wrote:
Hi!

> I vaguely recall that the problem was in
> org.apache.jcs.auxiliary.disk:dispose().
> The alive flag is set to false before calling the actual dispose which lead
> to an early return. In the mailing list archive somebody had submitted a
> patch for this a while ago for review, I guess it got lost.
Yes, that's right. I patched the disk cache in that way. It was quite easy 
since the only thing that has to be done, is setting alive from false 
to true in the proper function. 

> Also I remember a timing problem with the event queue. In case of many
> elements left in the queue the cache might shut down to soon and the last
> elements might not have been written before the destroy. The patch included
> a simple delay as a hotfix.
I added a method isEmpty which checks if the event cache event queue is empty. 
This should be invoked right before dispose is called.

I have included my changes and hope that someone will check them. 

Concerning the alive flag which is used throughout the whole tool, I would 
like to know why so many methods do have the right to change it. From my 
point of view, only one method per cache type should be able to toggle it. I 
think that the concrete dispose methods should be the ones to set it to 
false. Therefore I removed alive = false from various methods.

ICacheEventQueue: I added a method isEmpty to the interface. This idea behind
it is, to check if the cache event queue is empty. This has to be called in 
AbstractDiskCache#dispose() to ensure that all elements are processed before 
the shutdown of the system.

CompositeCache#dispose(): The setting of alive from true to false has to be
removed.

CacheEventQueue: Implemented isEmpty from the ICacheEventQueue interface.
The method returns the boolean value of head == tail.

AbstractDiskCache#dispose: The method ICacheEventQueue#isEmpty is constantly 
called until the return value is true. Then doDispose() has to be called.
The alive flag which has been set to false at the beginning of the method, has 
to be removed.

With regards,
  Christian