portals-jetspeed-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Sean Taylor <da...@bluesunrise.com>
Subject Re: Jetspeed Cache Question
Date Mon, 05 Nov 2007 21:16:56 GMT

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


Mime
View raw message