jakarta-jcs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Kreutzfeldt <christian.kreutzfe...@gmx.de>
Subject [jcs] fixes
Date Thu, 07 Aug 2003 14:44:33 GMT

I just started playing around with jcs again and I came across a problem
that I figured out when I used jcs the last time. If my mind serves me right,
we had a short discussion about that months ago. It is about the 

When I place elements in that cache and call


(where indexedCache is referenced to the IndexedDiskCache implementation in 
the cache.ccf)

none of the elements gets saved to the disk. Okay, the time, my testing 
program is running, is quite short, but overall I expect the cache to save my 
items. I just started skimming through the source code to figure out how the 
control flow is organized in this project.
During that process, I came acress some things which I found that they would 
be easier to understand if they get changed. I hope it is not too affronting 
to tell you my opinion :-)

I found out that you use quite a lot of inner classes. Wouldn't it be good      
to extract these to own java files? You would probably need some new packages 
to keep track of all the classes and structures, but it would help to 
understand the flow of control.

For example, all these Event-Classes (Put, Remove etc) in CacheEventQueue 
could be easily extracted, the CacheListener in AbstractDiskCache. Especially 
the last class is a little bit tricky to understand because the listener 
class calls a method doUpdate which is referenced as method of 
AbstractDiskCache. Why don't you pass a parent object of type 
AbstractDiskCache as constructor parameter and call doUpdate on that object?

When I call 
CompositeCache#dispose(boolean) is called. Here the alive flag is set to 
false. Unfortunately IndexedDiskCache#doUpdate( ICacheElement ) relies on 
that flag. 
If the flag is set to false, the save operation never gets called. And that is 
what happens, when I try to dispose the cache. So, I have to wait for the 
QProcessor (which I also would move into an own class) to process the whole 
queue before I can call dispose.

What about the following idea. I added a method boolean isEmpty() to the 
ICacheEventQueue class which returns the result of tail == head which 
indicates that the queue is empty. When I call dispose at the 
AbstractDiskCache, the method dispose waits as long as 
ICacheEventQueue#isEmpty returns true. This leads to a clean shutdown - in 
the case of the indexed disk cache

As mentioned in (2), the alive flag is from my point of view, a kind of a show 
stopper when it comes when it comes to the final clean up. It prevents some 
highly required methods from being run eg. the save process of the keys and 
its associated values.
From my point of view, only one method in the whole dispose process should 
have have the right to set alive to false. And I think it should be done by 
that method that handles the dispose request, which is in my case 
IndexedDiskCache#doDispose. Therefore I kicked the line alive = false from 
the following classes:

AbstractDiskCache#dispose() - I also added a check that waits for the 
QProcessor to finish the event queue


Additionally, I added the method isEmpty to the following classes. This method 
is invoked by AbstractDiskCache#dispose() which waits till the last element 
has been processed by the cache processor.

ICacheEventQueue - added isEmpty to the interface
CacheEventQueue - implemented the interface method

Concerning the properties loader. Why do you only supply a method that loads 
the properties via the class loader? I added for myself a method that 
retrieves the config file from every position you want. (eg. RemoteUtils)

It would be good to have the RMI stubs and skeletons generated automatically. 
I had to do this by hand, never knowing which classes need to be processed. 
Beside that I added an Exception to IRemoteCacheService#setGroupKeys because
the compiler was complaining about the lack of this.
This also caused a changement in RemoteCache where getGroupKeys needs to catch 
the exception.

The dispose operation seems to be a problem with the remote cache too. When it 
comes to the dispose operation, an event is added to the queue. Since this is 
the same problem as with the IndexedDiskCache, I replaced the line 

qList[i].addDisposeEvent in RemoteCacheServer#release with

The dispose operation is then in charge of what happens then. In the case of 
the AbstractDiskCache, the dispose waits until the queue is empty.

The RemoteCacheServerFactory needs a checkup since the main-method causes a 
lot of trouble. The reason for the trouble is the parsing of the input 
parameters. It would be cool to have something like in C/C++ tools where you 
can use this standard operation. If you want to have something like that, I 
could have a look on that.

I replaced some code fragments like rca.LOCAL in RemoteCacheFactory by 
RemoteCacheAttributes.LOCAL since it produces warnings.

If you are interested in my source code, I could mail it to you.

With regards,
  Christian Kreutzfeldt

View raw message