I originally posted this on the
turbine-jcs-user@jakarta.apache.org mailing list. But, it actually might be more of a problem with how Hibernate uses JCS. Basically, what we're seeing is one extra thread (a JCS ElementEventQueue) being created for EACH object marked with jcs-cache. I've since switched over to HashtableCache with my own custom CacheProvider and everything works fine.
Here's the thread for those interested. I had to paste it together from multiple posts, so the >> indents aren't exactly correct.
START THREAD:
To: "Turbine JCS Users List" <turbine-jcs-user@jakarta.apache.org>
Subject: RE: RE: ElementEventQueue question
Looks like Hiberate creates a new JCS cache region for each object you want cached. Each region has its OWN ElementEventQueue (to maximize throughput, I'd assume). What I did is switch to Hibernate's HashtableCache since I really only need a simple, in-memory, read-only cache (no failover, etc). It was in v2.1b3, but has recently been moved to the Attic in CVS. I just wrote my own simple HashtableCache (implements Hibernates Cache interface) and HashtableCacheProvider. Then you declare your provider in hibernate.cfg.xml (or hibernate.properties) like so:
Code:
hibernate.connection.provider_class=some.package.HashtableCacheProvider
You also have to change your <jcs-cache usage="" /> tags to <cache usage="" />. That's it! This gives you more caching flexibility, since you can control what type of cache is instantiated for each object you want to cache.
By the way, I'm in no way disrespecting JCS. I think it's a fine product. Hibernate MAY be misusing it in this case. Either way, switching to a simpler caching strategy has worked out great for me. I'll cross-post this on the hibernate forum. Good luck!
-nick
At 02:10 PM 10/31/2003 -0500, you wrote:
I have a similar problem to Nicholas. I am using hibernate and have
identified 46 classes to use JCS caching. I have 46 ElementEventQueue
threads running in my application. My cache.ccf is much simpler than
Nicholas', and setting the MemoryShrinker to false has no impact on the
threads existence/behavior. I use my own implementation for the memory
cache (just a wrapper around HashMap) because of the memory leak problems
with LRUMemoryCache, but I had the same behavior of the ElementEventQueue
threads when I was using LRUMemoryCache.
Any other ideas as to why these threads exist and how to get rid of them (if
they aren't doing anything useful).
Sarah Hand
To: "Turbine JCS Users List" <turbine-jcs-user@jakarta.apache.org>
Subject: RE: RE: ElementEventQueue question
No matter what I put in my cache.ccf file, I still get the 7 threads popping up. I removed the memory shrinker lines and I added an auxillary cache section to get rid of the ERRORs in the log output.
I think this may have something to do with hibernate itself. I declared <jcs-cache usage-"read-only" on 7 of my domain objects (hence 7 threads). I tried removing jcs-cache from a few of my hibernate mappings I got it down to 4 threads (there was not a directly correlation between the number of threads running and the number of jcs-cached objects in my system). Is this just the way JCS works? Do there really need to be that many ElementEventQueues... I guess if you want very high throughput, you'd need lots of threads to handle all the cache puts and gets... Is hibernate possibly initializing JCS incorrectly? (here's the code it uses to access JCS
http://cvs.sourceforge.net/viewcvs.py/* ... ev=1.5.2.3One other strange thing is this log output for each domain object I have the jcs-cache flag set in:
Code:
WARN 14:39:40,674 (OptionConverter.instantiateByKey():189): ---> Could not find value for key jcs.region.gov.llnl.ais.domain.person.Person.cacheattributes
WARN 14:39:40,674 (CompositeCacheConfigurator.parseCompositeCacheAttributes():339): ---> Could not instantiate ccAttr named 'jcs.region.gov.llnl.ais.domain.person.Person.cacheattributes', using defaults.
Thanks for your help. I'll keep tweaking things and see what I can come up with. I can probably live with 7 threads if they just sit there. I'm just worried about them multiplying for some reason and hosing my app in production...
-nick
At 12:50 PM 10/30/2003 -0600, you wrote:
I'm surprised that it works with all those periods in the name of your
region. I'm not sure this will parse correctly. Remove the periods.
Replace them with _ and test.
You have the memory shrinker on but have not defined a maxlife seconds.
I think the default in this case is to treat the element as if it is
eternal. Basically, this starts a thread that iterates through the map
and doesn't do anything else. Just set the shrinker to false.
I'd like to see what happens if the shrinker is off.
Aaron
> -----Original Message-----
> From: Nicholas J. Dellamaggiore [mailto:dellamaggiore1@llnl.gov]
> Sent: Wednesday, October 29, 2003 11:22 PM
> To: Turbine JCS Users List
> Subject: RE: RE: ElementEventQueue question
>
> It is pasted lower down in the thread. Here it is again. I truncated
out
> some redundant sections for brevity. Thanks for your help.
>
> -nick
>
> # DEFAULT CACHE REGION (memory cache)
> jcs.default=DC
>
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttribut
es
> jcs.default.cacheattributes.MaxObjects=10000
>
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory
.l
> ru.LRUMemoryCache
> jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
> jcs.default.elementattributes.IsEternal=false
> jcs.default.elementattributes.IsSpool=false
> jcs.default.elementattributes.IsRemote=false
> jcs.default.elementattributes.IsLateral=false
>
> # merged report categories cache
> jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory=DC
>
jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.cacheattri
bu
> tes.MaxObjects=1000
>
jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.cacheattri
bu
> tes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
>
jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.cacheattri
bu
> tes.UseMemoryShrinker=true
>
jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.cacheattri
bu
> tes.ShrinkerIntervalSeconds=60
>
jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.elementatt
ri
> butes=org.apache.jcs.engine.ElementAttributes
>
jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.elementatt
ri
> butes.IsEternal=false
>
jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.elementatt
ri
> butes.IsSpool=false
>
jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.elementatt
ri
> butes.IsRemote=false
>
jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.elementatt
ri
> butes.IsLateral=false
>
> ############# etc
>
> At 12:04 AM 10/30/2003 -0600, you wrote:
> >Paste your config file in an email.
> >
> > > -----Original Message-----
> > > From: Nicholas J. Dellamaggiore [mailto:dellamaggiore1@llnl.gov]
> > > Sent: Wednesday, October 29, 2003 10:01 PM
> > > To:
turbine-jcs-user@jakarta.apache.org
> > > Subject: Fwd: RE: ElementEventQueue question
> > >
> > > The thread problem is actually pretty bad. We left out app
running
> > > overnight and found like 30 threads ElementEventQueue threads
> > > running! This is obviously a misconfiguration issue on our part.
So,
> >how
> > > exactly do you set up cache.ccf so no auxillary cache is used?
I'd
> >rather
> > > not introduce any more complexity our app (like a disk overflow
> >cache)...
> > > Thanks!
> > >
> > > -nick
> > >
> > > >Date: Sun, 26 Oct 2003 23:13:09 -0700
> > > >To: "Turbine JCS Users List"
<turbine-jcs-user@jakarta.apache.org>
> > > >From: "Nicholas J. Dellamaggiore" <dellamaggiore1@llnl.gov>
> > > >Subject: RE: ElementEventQueue question
> > > >
> > > >Things are working as far as I can tell (things seem faster). I
> >don't
> > > >think I have an auxillary cache. Its all in memory (read-only
> >caching).
> > > I
> > > >noticed some warnings at startup. The Hibernate forums said to
ignore
> > > >them. After looking over the output, I noticed that there are 7
> >errors
> > > >(one for each thread, perhaps?) while trying to create an
auxFactory.
> >Do
> > > >I need to add an auxillary cache? Or can I go on without one? The
> >cache
> > > >isn't mission critical. I just want to cache some read-only in a
> > > clustered
> > > >environment. Thanks for your quick reply
> > > >
> > > >-nick
> > > >
> > > >Here's my cache.ccf and the startup log output:
> > > >
> > > >cache.ccf (modified from
http://hibernate.org/61.html)
> > > >
> > > ># DEFAULT CACHE REGION (memory cache)
> > > >jcs.default=DC
> > >
> >
>jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttribu
> >te
> > > s
> > > >jcs.default.cacheattributes.MaxObjects=10000
> > >
> >
>jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memor
> >y.
> > > lru.LRUMemoryCache
> > >
>jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
> > > >jcs.default.elementattributes.IsEternal=false
> > > >jcs.default.elementattributes.IsSpool=false
> > > >jcs.default.elementattributes.IsRemote=false
> > > >jcs.default.elementattributes.IsLateral=false
> > > >
> > > ># merged report categories cache
> > > >jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory=DC
> > >
> >
>jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.cacheattr
> >ib
> > > utes.MaxObjects=1000
> > >
> >
>jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.cacheattr
> >ib
> > >
utes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
> > >
> >
>jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.cacheattr
> >ib
> > > utes.UseMemoryShrinker=true
> > >
> >
>jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.cacheattr
> >ib
> > > utes.ShrinkerIntervalSeconds=60
> > >
> >
>jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.elementat
> >tr
> > > ibutes=org.apache.jcs.engine.ElementAttributes
> > >
> >
>jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.elementat
> >tr
> > > ibutes.IsEternal=false
> > >
> >
>jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.elementat
> >tr
> > > ibutes.IsSpool=false
> > >
> >
>jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.elementat
> >tr
> > > ibutes.IsRemote=false
> > >
> >
>jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.elementat
> >tr
> > > ibutes.IsLateral=false
> > > >
> > > >###### REPEAT FOR OTHER OBJECTS
> > > >
> > > >Log output:
> > > >
> > > >...
> > > > INFO 23:08:11,151 (SettingsFactory.buildSettings():99): --->
Query
> > > > language substitutions: {}
> > > > INFO 23:08:11,167 (SettingsFactory.buildSettings():110): --->
cache
> > > > provider: net.sf.hibernate.cache.JCSCacheProvider
> > > > INFO 23:08:11,167 (Configuration.configureCaches():930): --->
> > > > instantiating and configuring caches
> > > > WARN 23:08:11,229 (OptionConverter.instantiateByKey():189):
--->
> >Could
> > > > not find value for key
> > > > jcs.region.gov.llnl.ais.im.common.auth.IMGroup.elementattributes
> > > > WARN 23:08:11,229
> > > > (CompositeCacheConfigurator.parseElementAttributes():375): --->
> >Could
> > > not
> > > > instantiate eAttr named
> > > >
'jcs.region.gov.llnl.ais.im.common.auth.IMGroup.elementattributes',
> > > using
> > > > defaults.
> > > > WARN 23:08:11,261 (OptionConverter.instantiateByKey():189):
--->
> >Could
> > > > not find value for key jcs.auxiliary.DC
> > > >ERROR 23:08:11,261
(CompositeCacheConfigurator.parseAuxiliary():413):
> >---
> > > >
> > > >Could not instantiate auxFactory named "DC".
> > > > WARN 23:08:11,261 (OptionConverter.instantiateByKey():189):
--->
> >Could
> > > > not find value for key
> > > >
> > >
>
>jcs.region.gov.llnl.ais.im.common.auth.IMGroup.permissions.elementattri
b
> >ut
> > > es
> > > > WARN 23:08:11,261
> > > > (CompositeCacheConfigurator.parseElementAttributes():375): --->
> >Could
> > > not
> > > > instantiate eAttr named
> > > >
> > >
>
>'jcs.region.gov.llnl.ais.im.common.auth.IMGroup.permissions.elementattr
i
> >bu
> > > tes',
> > > > using defaults.
> > > > WARN 23:08:11,261 (OptionConverter.instantiateByKey():189):
--->
> >Could
> > > > not find value for key jcs.auxiliary.DC
> > > >ERROR 23:08:11,261
(CompositeCacheConfigurator.parseAuxiliary():413):
> >---
> > > >
> > > >Could not instantiate auxFactory named "DC".
> > > > WARN 23:08:11,261 (OptionConverter.instantiateByKey():189):
--->
> >Could
> > > > not find value for key
> > > >
> > >
>
>jcs.region.gov.llnl.ais.im.common.domain.org.LLNLOrgNode.elementattribu
t
> >es
> > > > WARN 23:08:11,261
> > > > (CompositeCacheConfigurator.parseElementAttributes():375): --->
> >Could
> > > not
> > > > instantiate eAttr named
> > > >
> > >
>
>'jcs.region.gov.llnl.ais.im.common.domain.org.LLNLOrgNode.elementattrib
u
> >te
> > > s',
> > > > using defaults.
> > > > WARN 23:08:11,261 (OptionConverter.instantiateByKey():189):
--->
> >Could
> > > > not find value for key jcs.auxiliary.DC
> > > >ERROR 23:08:11,261
(CompositeCacheConfigurator.parseAuxiliary():413):
> >---
> > > >
> > > >Could not instantiate auxFactory named "DC".
> > > > WARN 23:08:11,261 (OptionConverter.instantiateByKey():189):
--->
> >Could
> > > > not find value for key
> > > >
> > >
>
>jcs.region.gov.llnl.ais.im.common.domain.ReportCategory.elementattribut
e
> >s
> > > > WARN 23:08:11,261
> > > > (CompositeCacheConfigurator.parseElementAttributes():375): --->
> >Could
> > > not
> > > > instantiate eAttr named
> > > >
> > >
>
>'jcs.region.gov.llnl.ais.im.common.domain.ReportCategory.elementattribu
t
> >es
> > > ',
> > > > using defaults.
> > > > WARN 23:08:11,261 (OptionConverter.instantiateByKey():189):
--->
> >Could
> > > > not find value for key jcs.auxiliary.DC
> > > >ERROR 23:08:11,276
(CompositeCacheConfigurator.parseAuxiliary():413):
> >---
> > > >
> > > >Could not instantiate auxFactory named "DC".
> > > > WARN 23:08:11,276 (OptionConverter.instantiateByKey():189):
--->
> >Could
> > > > not find value for key
> > > >
> > >
>
>jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.elementat
t
> >ri
> > > butes
> > > > WARN 23:08:11,276
> > > > (CompositeCacheConfigurator.parseElementAttributes():375): --->
> >Could
> > > not
> > > > instantiate eAttr named
> > > >
> > >
>
>'jcs.region.gov.llnl.ais.im.common.domain.MergedReportCategory.elementa
t
> >tr
> > > ibutes',
> > > > using defaults.
> > > > WARN 23:08:11,276 (OptionConverter.instantiateByKey():189):
--->
> >Could
> > > > not find value for key jcs.auxiliary.DC
> > > >ERROR 23:08:11,276
(CompositeCacheConfigurator.parseAuxiliary():413):
> >---
> > > >
> > > >Could not instantiate auxFactory named "DC".
> > > > WARN 23:08:11,276 (OptionConverter.instantiateByKey():189):
--->
> >Could
> > > > not find value for key
> > > > jcs.region.gov.llnl.ais.domain.person.Person.elementattributes
> > > > WARN 23:08:11,276
> > > > (CompositeCacheConfigurator.parseElementAttributes():375): --->
> >Could
> > > not
> > > > instantiate eAttr named
> > > >
'jcs.region.gov.llnl.ais.domain.person.Person.elementattributes',
> >using
> > > > defaults.
> > > > WARN 23:08:11,292 (OptionConverter.instantiateByKey():189):
--->
> >Could
> > > > not find value for key jcs.auxiliary.DC
> > > >ERROR 23:08:11,292
(CompositeCacheConfigurator.parseAuxiliary():413):
> >---
> > > >
> > > >Could not instantiate auxFactory named "DC".
> > > > WARN 23:08:11,292 (OptionConverter.instantiateByKey():189):
--->
> >Could
> > > > not find value for key
> > > >
> >jcs.region.gov.llnl.ais.im.common.auth.IMPermission.elementattributes
> > > > WARN 23:08:11,292
> > > > (CompositeCacheConfigurator.parseElementAttributes():375): --->
> >Could
> > > not
> > > > instantiate eAttr named
> > > >
>
>'jcs.region.gov.llnl.ais.im.common.auth.IMPermission.elementattributes'
,
> > > > using defaults.
> > > > WARN 23:08:11,292 (OptionConverter.instantiateByKey():189):
--->
> >Could
> > > > not find value for key jcs.auxiliary.DC
> > > >ERROR 23:08:11,292
(CompositeCacheConfigurator.parseAuxiliary():413):
> >---
> > > >
> > > >Could not instantiate auxFactory named "DC".
> > > > INFO 23:08:11,604 (SessionFactoryImpl.<init>():112): --->
building
> > > > session factory
> > > >...
> > > >
> > > >
> > > >
> > > >At 12:47 AM 10/27/2003 -0600, you wrote:
> > > >>That doesn't sound right. Those threads are trying to perform
some
> > > >>event to an auxiliary cache. Is everything working? Does the
disk
> > > >>cache have write access to the file? Do you have laterals that
> >might be
> > > >>blocked by a firewall?
> > > >>
> > > >>Aaron
> > > >>
> > > >> > -----Original Message-----
> > > >> > From: Nicholas J. Dellamaggiore
[mailto:dellamaggiore1@llnl.gov]
> > > >> > Sent: Sunday, October 26, 2003 11:41 PM
> > > >> > To:
turbine-jcs-user@jakarta.apache.org
> > > >> > Subject: ElementEventQueue question
> > > >> >
> > > >> > Hi. I'm using JCS with hibernate and it's working great. I'm
was
> > > >>debugging
> > > >> > in Eclipse and I happened to notice that there are 7
> > > ElementEventQueue
> > > >> > threads started up. I know there are just sitting there
blocking,
> >but
> > > >>I
> > > >> > get
> > > >> > worried about having lots of extra threads running around. Is
> >there a
> > > >> > setting to tweak the number of EventQueues? Thanks.
> > > >> >
> > > >> > -nick
> > > >> >
> > > >> >
> > > >> >
> >---------------------------------------------------------------------
> > > >> > To unsubscribe, e-mail:
> > > >>turbine-jcs-user-unsubscribe@jakarta.apache.org
> > > >> > For additional commands, e-mail:
> > > >>turbine-jcs-user-help@jakarta.apache.org
> > > >>
> > > >>
> > >
> >
>>---------------------------------------------------------------------
> > > >>To unsubscribe, e-mail:
> >turbine-jcs-user-unsubscribe@jakarta.apache.org
> > > >>For additional commands, e-mail: turbine-jcs-user-
> > >
help@jakarta.apache.org
> > > >
> > > >/**
> > > > * Nicholas J. Dellamaggiore
> > > > * Software Developer (AIS/IBIS)
> > > > * Phone: x26585
> > > > * Office: B671 R2321
> > > > * ICQ: 162919183 AIM: wontonsoup79
> > > > */
> > >
> > > /**
> > > * Nicholas J. Dellamaggiore
> > > * Software Developer (AIS/IBIS)
> > > * Phone: x26585
> > > * Office: B671 R2321
> > > * ICQ: 162919183 AIM: wontonsoup79
> > > */
> > >
> > >
> > >
---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> >turbine-jcs-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> >turbine-jcs-user-help@jakarta.apache.org
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail:
turbine-jcs-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail:
turbine-jcs-user-help@jakarta.apache.org
>
> /**
> * Nicholas J. Dellamaggiore
> * Software Developer (AIS/IBIS)
> * Phone: x26585
> * Office: B671 R2321
> * ICQ: 162919183 AIM: wontonsoup79
> */
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
turbine-jcs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
turbine-jcs-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail:
turbine-jcs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail:
turbine-jcs-user-help@jakarta.apache.org
/**
* Nicholas J. Dellamaggiore
* Software Developer (AIS/IBIS)
* Phone: x26585
* Office: B671 R2321
* ICQ: 162919183 AIM: wontonsoup79
*/