You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by "Sie, Yang" <ya...@fmr.com> on 2007/11/05 21:27:41 UTC

Jetspeed Cache Question

Hello all:

I am trying to monitor memory consumption for all cache objects in
Jetspeed. This is what I did and for some reason that memoryStoreSize
and calculateInMemorySize gave me zero.

This is what I did basically by using EhCache API:

import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;

CacheManager ehCacheManager=CacheManager.getInstance();
String[] cacheNames=ehCacheManager.getCacheNames();

I looped thru the names and get 6 cache object names (which matches what
defined in ehcache.xml)

preferencesCache
portletApplicationNameCache
portletDefinitionOidCache 
portletDefinitionNameCache 
portletApplicationOidCache 
portletContentCache

Then I used following

 Cache thisCache=ehCacheManager.getCache(aCacheName);
 long mss=thisCache.getMemoryStoreSize();
 long ims=thisCache.calculateInMemorySize();

to try to get memoryStoreSize and calculateInMemorySize. Both mss and
ims yield zero. What did I do wrong?  Please advise. Thank you.

---Yang

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: Jetspeed Cache Question

Posted by David Sean Taylor <da...@bluesunrise.com>.
On Nov 5, 2007, at 12:27 PM, Sie, Yang wrote:

> Hello all:
>
> I am trying to monitor memory consumption for all cache objects in
> Jetspeed. This is what I did and for some reason that memoryStoreSize
> and calculateInMemorySize gave me zero.
>
> This is what I did basically by using EhCache API:
>
> import net.sf.ehcache.Cache;
> import net.sf.ehcache.CacheManager;
>
> CacheManager ehCacheManager=CacheManager.getInstance();
> String[] cacheNames=ehCacheManager.getCacheNames();
>
> I looped thru the names and get 6 cache object names (which matches  
> what
> defined in ehcache.xml)
>
> preferencesCache
> portletApplicationNameCache
> portletDefinitionOidCache
> portletDefinitionNameCache
> portletApplicationOidCache
> portletContentCache
>
> Then I used following
>
>  Cache thisCache=ehCacheManager.getCache(aCacheName);
>  long mss=thisCache.getMemoryStoreSize();

This API returns the number of elements in the memory store.
Could it be possible that we haven't loaded any prefs yet at this point?


>  long ims=thisCache.calculateInMemorySize();

    This call gets the size of the memory store for this cache.  
Perhaps if its not yet in use, it returns 0.
According to the javadocs:

     Warning: This method can be very expensive to run. Allow  
approximately 1 second per 1MB of entries.
    Running this method could create liveness problems because the  
object lock is held for a long period

     Returns:
         the approximate size of the memory store in bytes


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: Jetspeed Cache Question

Posted by Vitaly Baranovsky <vi...@gmail.com>.
Hi, Sie!

Are you writing servlet for monitoring caches? We need such monitoring
servlet too.

Can you share it? For example, by seding .war file into this mailing
list or by giving a link to .war?

Thanks!

2007/11/5, Sie, Yang <ya...@fmr.com>:
> Hello all:
>
> I am trying to monitor memory consumption for all cache objects in
> Jetspeed. This is what I did and for some reason that memoryStoreSize
> and calculateInMemorySize gave me zero.
>
> This is what I did basically by using EhCache API:
>
> import net.sf.ehcache.Cache;
> import net.sf.ehcache.CacheManager;
>
> CacheManager ehCacheManager=CacheManager.getInstance();
> String[] cacheNames=ehCacheManager.getCacheNames();
>
> I looped thru the names and get 6 cache object names (which matches what
> defined in ehcache.xml)
>
> preferencesCache
> portletApplicationNameCache
> portletDefinitionOidCache
> portletDefinitionNameCache
> portletApplicationOidCache
> portletContentCache
>
> Then I used following
>
>  Cache thisCache=ehCacheManager.getCache(aCacheName);
>  long mss=thisCache.getMemoryStoreSize();
>  long ims=thisCache.calculateInMemorySize();
>
> to try to get memoryStoreSize and calculateInMemorySize. Both mss and
> ims yield zero. What did I do wrong?  Please advise. Thank you.
>
> ---Yang
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>


-- 
With best regards,
Vitaly Baranovsky

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org