Hello Vitaly:

Sorry for the belated reply, I was out of office for a few days.

See below. I put this in a jsp file and put it right under /jetspeed at
this point.

Also, if you don't want to include Jetspeed library, you may enable the
"shared" in /assembly/cache.xml file as:
<bean id="cacheManager"
   class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
   <!--  get it through the class path
     <property name="configLocation"
value="${applicationRoot}/WEB-INF/conf/ehcache.xml"/>
    -->
    <!-- <property name="shared" value="true" /> -->
</bean>

This way, you don't need to use the jetspeed API and you can use 
//CacheManager ehCacheManager=CacheManager.getInstance(); as commented
out in the following... Either way will work...

---------------- jsCacheMonitor.jsp ---------------

<[EMAIL PROTECTED] import="net.sf.ehcache.Cache"%>
<[EMAIL PROTECTED] import="net.sf.ehcache.CacheManager"%>
<[EMAIL PROTECTED] import="net.sf.ehcache.Element"%>
<[EMAIL PROTECTED] import="java.lang.Long"%>
<[EMAIL PROTECTED] import="org.apache.jetspeed.Jetspeed"%>
<[EMAIL PROTECTED] import="org.apache.jetspeed.components.ComponentManager"%>


<%@ page contentType="text/html" %>
<html>
  <title>Equity Portal</title>
  <link rel="stylesheet" type="text/css" media="screen,print,projection"
href="decorations/layout/bos-eq/css/styles.css"  />
  <body>
    <div class="banner">
     <table class="table">
      <tr>
        <td class="appname"><img
src="decorations/layout/bos-eq/images/portal_logo_fmrco.GIF" width="255"
/></td>
        <td>&nbsp;</td>
      </tr>
     </table>
   </div>
   <p>
   
        <%
        //CacheManager ehCacheManager=CacheManager.getInstance();
        CacheManager ehCacheManager=(CacheManager) 
        Jetspeed.getComponentManager().getComponent("cacheManager");

        String[] cacheNames=ehCacheManager.getCacheNames();
        int noc=cacheNames.length;
        %>
        Total Number of Cache Objects in fep: <%=noc%>
   <table>
     <tr>
      <td>CacheName</td>
      <td>MemoryStoreSize</td>
      <td>InMemorySize</td>
     </tr>
<%
for (int i=0;i<noc;i++)
{
 String cacheName=cacheNames[i];
 Cache thisCache=ehCacheManager.getCache(cacheName);
 long mss=thisCache.getMemoryStoreSize();
 long ims=thisCache.calculateInMemorySize();
%>     
     <tr>
       <td><%=cacheName%></td>
       <td><%=mss%></td>
       <td><%=ims%></td>
     </tr>
   
<%
}
%>   
   </table>
   

  </body>
</html> 


>-----Original Message-----
>From: Vitaly Baranovsky [mailto:[EMAIL PROTECTED] 
>Sent: Friday, November 23, 2007 7:45 AM
>To: Jetspeed Users List
>Subject: Re: Jetspeed Cache Question
>
>
>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 <[EMAIL PROTECTED]>:
>> 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: [EMAIL PROTECTED]
>> For additional commands, e-mail: 
>[EMAIL PROTECTED]
>>
>>
>
>
>-- 
>With best regards,
>Vitaly Baranovsky
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to