You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2009/05/10 05:34:14 UTC

svn commit: r773303 - in /portals/jetspeed-2/portal/trunk: applications/jetspeed/src/main/webapp/WEB-INF/min-pages/Administrative/portal-admin/ applications/jetspeed/src/main/webapp/WEB-INF/pages/Administrative/ components/jetspeed-cm/src/main/java/org...

Author: taylor
Date: Sun May 10 03:34:13 2009
New Revision: 773303

URL: http://svn.apache.org/viewvc?rev=773303&view=rev
Log:
https://issues.apache.org/jira/browse/JS2-997
cache monitor

Added:
    portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/CacheMonitorStateImpl.java   (with props)
    portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/JetspeedCacheMonitorImpl.java   (with props)
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/CacheMonitorState.java   (with props)
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/JetspeedCacheMonitor.java   (with props)
Modified:
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/Administrative/portal-admin/statistics.psml
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/Administrative/statistics.psml
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/CommonPortletServices.java
    portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/cache.xml
    portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-services.xml

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/Administrative/portal-admin/statistics.psml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/Administrative/portal-admin/statistics.psml?rev=773303&r1=773302&r2=773303&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/Administrative/portal-admin/statistics.psml (original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/Administrative/portal-admin/statistics.psml Sun May 10 03:34:13 2009
@@ -22,6 +22,14 @@
   <title>Portal Statistics</title>
 
   <fragment id="stats-2" type="layout" name="jetspeed-layouts::VelocityOneColumn">
-    <fragment id="stats-3" type="portlet" name="j2-admin::StatisticsPortlet" />
+    <fragment id="stats-3" type="portlet" name="j2-admin::StatisticsPortlet" >
+            <property name="row" value="1"/>
+            <property name="column" value="0"/>
+	</fragment>    
+	<fragment id="stats-4" type="portlet" name="j2-admin::CacheMonitor">
+            <property name="row" value="0"/>
+            <property name="column" value="0"/>
+    </fragment>    
   </fragment>
+
 </page>

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/Administrative/statistics.psml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/Administrative/statistics.psml?rev=773303&r1=773302&r2=773303&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/Administrative/statistics.psml (original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/Administrative/statistics.psml Sun May 10 03:34:13 2009
@@ -23,6 +23,14 @@
   <title>Portal Statistics</title>
 
   <fragment id="stats-2" type="layout" name="jetspeed-layouts::VelocityOneColumn">
-    <fragment id="stats-3" type="portlet" name="j2-admin::StatisticsPortlet" />
+    <fragment id="stats-3" type="portlet" name="j2-admin::StatisticsPortlet" >
+            <property name="row" value="1"/>
+            <property name="column" value="0"/>
+	</fragment>    
+	<fragment id="stats-4" type="portlet" name="j2-admin::CacheMonitor">
+            <property name="row" value="0"/>
+            <property name="column" value="0"/>
+    </fragment>    
   </fragment>
+
 </page>

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/CacheMonitorStateImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/CacheMonitorStateImpl.java?rev=773303&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/CacheMonitorStateImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/CacheMonitorStateImpl.java Sun May 10 03:34:13 2009
@@ -0,0 +1,215 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.cache.impl;
+
+import org.apache.jetspeed.cache.CacheMonitorState;
+
+
+public class CacheMonitorStateImpl implements CacheMonitorState
+{
+    private String name;
+    private float averageGetTime;
+    private long cacheHits;
+    private long cacheMisses;
+    private long diskStoreSize;
+    private long evictionCount;
+    private long inMemoryHits;
+    private long inMemorySize;
+    private long memoryStoreSize;
+    private long objectCount;
+    private long size;
+    private long onDiskHits;  
+    private long maxElementsInMemory;
+    private long maxElementsOnDisk;
+    private long timeToIdle;
+    private long timeToLive;
+    
+    public CacheMonitorStateImpl(String name)
+    {
+        this.name = name;
+    }
+
+    public String getCacheName()
+    {
+        return name;
+    }
+    
+    public float getAverageGetTime()
+    {
+        return averageGetTime;
+    }
+
+    public long getCacheHits()
+    {
+        return cacheHits;
+    }
+
+    public long getCacheMisses()
+    {
+        return cacheMisses;
+    }
+
+    public long getDiskStoreSize()
+    {
+        return diskStoreSize;
+    }
+
+    public long getEvictionCount()
+    {
+        return evictionCount;
+    }
+
+    public long getInMemoryHits()
+    {
+        return inMemoryHits;
+    }
+
+    public long getInMemorySize()
+    {
+        return inMemorySize;
+    }
+
+    public long getMemoryStoreSize()
+    {
+        return memoryStoreSize;
+    }
+
+    public long getObjectCount()
+    {
+        return objectCount;
+    }
+    
+    public long getSize()
+    {
+        return size;
+    }
+
+    public long getOnDiskHits()
+    {
+        return onDiskHits;
+    }
+    
+    
+    public long getMaxElementsInMemory()
+    {
+        return maxElementsInMemory;
+    }
+
+    public long getMaxElementsOnDisk()
+    {
+        return maxElementsOnDisk;
+    }
+    
+    public long getTimeToIdle()
+    {
+        return timeToIdle;
+    }
+
+    public long getTimeToLive()
+    {
+        return timeToLive;
+    }        
+    
+    protected void setAverageGetTime(float averageGetTime)
+    {
+        this.averageGetTime = averageGetTime;
+    }
+
+    
+    protected void setCacheHits(long cacheHits)
+    {
+        this.cacheHits = cacheHits;
+    }
+
+    
+    protected void setCacheMisses(long cacheMisses)
+    {
+        this.cacheMisses = cacheMisses;
+    }
+
+    
+    protected void setDiskStoreSize(long diskStoreSize)
+    {
+        this.diskStoreSize = diskStoreSize;
+    }
+
+    
+    protected void setEvictionCount(long evictionCount)
+    {
+        this.evictionCount = evictionCount;
+    }
+
+    
+    protected void setInMemoryHits(long inMemoryHits)
+    {
+        this.inMemoryHits = inMemoryHits;
+    }
+
+    
+    protected void setInMemorySize(long inMemorySize)
+    {
+        this.inMemorySize = inMemorySize;
+    }
+
+    
+    protected void setMemoryStoreSize(long memoryStoreSize)
+    {
+        this.memoryStoreSize = memoryStoreSize;
+    }
+
+    
+    protected void setObjectCount(long objectCount)
+    {
+        this.objectCount = objectCount;
+    }
+
+    
+    protected void setSize(long size)
+    {
+        this.size = size;
+    }
+
+    
+    protected void setOnDiskHits(long onDiskHits)
+    {
+        this.onDiskHits = onDiskHits;
+    }
+ 
+    
+    protected void setMaxElementsInMemory(long maxElementsInMemory)
+    {
+        this.maxElementsInMemory = maxElementsInMemory;
+    }
+
+    
+    protected void setMaxElementsOnDisk(long maxElementsOnDisk)
+    {
+        this.maxElementsOnDisk = maxElementsOnDisk;
+    }
+
+    
+    protected void setTimeToIdle(long timeToIdle)
+    {
+        this.timeToIdle = timeToIdle;
+    }
+
+    protected void setTimeToLive(long timeToLive)
+    {
+        this.timeToLive = timeToLive;
+    }
+    
+}
\ No newline at end of file

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/CacheMonitorStateImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/CacheMonitorStateImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/JetspeedCacheMonitorImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/JetspeedCacheMonitorImpl.java?rev=773303&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/JetspeedCacheMonitorImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/JetspeedCacheMonitorImpl.java Sun May 10 03:34:13 2009
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.cache.impl;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import net.sf.ehcache.Cache;
+import net.sf.ehcache.CacheManager;
+import net.sf.ehcache.Statistics;
+
+import org.apache.jetspeed.cache.CacheMonitorState;
+import org.apache.jetspeed.cache.JetspeedCacheMonitor;
+
+public class JetspeedCacheMonitorImpl implements JetspeedCacheMonitor
+{
+    private CacheManager cacheManager;
+    private boolean calculateObjectCount = false;
+    private Map<String, CalculatedState> calculatedStates = Collections.synchronizedMap(new HashMap<String, CalculatedState>()); 
+    
+    public JetspeedCacheMonitorImpl(CacheManager cacheManager)
+    {
+        this.cacheManager = cacheManager;
+    }
+    
+    public List<CacheMonitorState> snapshotStatistics()
+    {
+        return snapshotAndCalculateStatistics(false) ;
+    }
+
+    public CacheMonitorState snapshotStatistics(String cacheName)
+    {
+        return snapshotAndCalculateStatistics(cacheName, false) ;
+    }
+    
+    public List<CacheMonitorState> calculateStatistics()
+    {
+        return snapshotAndCalculateStatistics(true);        
+    }
+    
+    public CacheMonitorState calculateStatistics(String cacheName)
+    {
+        return snapshotAndCalculateStatistics(cacheName, true);
+    }
+    
+    public void resetStatistics()
+    {
+        String[]names = cacheManager.getCacheNames();
+        for (String name : names)
+        {
+            resetStatistics(name);
+        }
+    }
+
+    public void resetStatistics(String cacheName)
+    {
+        Cache cache = cacheManager.getCache(cacheName);
+        cache.clearStatistics();
+        calculatedStates.remove(cacheName);
+    }
+ 
+    protected List<CacheMonitorState> snapshotAndCalculateStatistics(boolean calculate)
+    {
+        List<CacheMonitorState> states = new LinkedList<CacheMonitorState>();        
+        String[]names = cacheManager.getCacheNames();
+        for (String name : names)
+        {
+            states.add(snapshotAndCalculateStatistics(name, calculate));
+        }
+        return states;        
+    }
+    
+    protected CacheMonitorState snapshotAndCalculateStatistics(String name, boolean calculate)
+    {
+        Cache cache = cacheManager.getCache(name);        
+        CacheMonitorStateImpl state = new CacheMonitorStateImpl(name);
+        Statistics statistics = cache.getStatistics();        
+        state.setMemoryStoreSize(cache.getMemoryStoreSize());
+        if (calculate)
+        {
+            state.setInMemorySize(cache.calculateInMemorySize());
+            if (calculateObjectCount)
+            {
+                state.setObjectCount(statistics.getObjectCount());
+            }
+            else
+            {
+                state.setObjectCount(0);
+            }
+            calculatedStates.put(name, new CalculatedState(state.getInMemorySize(), state.getObjectCount()));
+        }
+        else
+        {
+            CalculatedState cs = calculatedStates.get(name);
+            if (cs == null)
+            {
+                state.setInMemorySize(0);                
+                state.setObjectCount(0);
+            }
+            else
+            {
+                state.setInMemorySize(cs.inMemorySize);
+                state.setObjectCount(cs.objectCount);
+            }            
+        }
+        state.setSize(cache.getSize());
+        state.setDiskStoreSize(cache.getDiskStoreSize());
+        state.setAverageGetTime(statistics.getAverageGetTime());
+        state.setCacheHits(statistics.getCacheHits());
+        state.setCacheMisses(statistics.getCacheMisses());
+        state.setEvictionCount(statistics.getEvictionCount());
+        state.setInMemoryHits(statistics.getInMemoryHits());
+        state.setOnDiskHits(statistics.getOnDiskHits());
+        state.setMaxElementsInMemory(cache.getCacheConfiguration().getMaxElementsInMemory());
+        state.setMaxElementsOnDisk(cache.getCacheConfiguration().getMaxElementsOnDisk());            
+        state.setTimeToIdle(cache.getCacheConfiguration().getTimeToIdleSeconds());
+        state.setTimeToLive(cache.getCacheConfiguration().getTimeToLiveSeconds());
+        return state;
+    }
+    
+    protected CacheManager getCacheManager()
+    {
+        return cacheManager;
+    }
+    
+    class CalculatedState implements Serializable
+    {
+        private long inMemorySize;
+        private long objectCount;
+        
+        CalculatedState(long inMemorySize, long objectCount)
+        {
+            this.inMemorySize = inMemorySize;
+            this.objectCount = objectCount;
+        }
+    }
+    
+}
\ No newline at end of file

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/JetspeedCacheMonitorImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/JetspeedCacheMonitorImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/CommonPortletServices.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/CommonPortletServices.java?rev=773303&r1=773302&r2=773303&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/CommonPortletServices.java (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/CommonPortletServices.java Sun May 10 03:34:13 2009
@@ -59,5 +59,5 @@
     public final static String CPS_JETSPEED_PRINCIPAL_MANAGER_PROVIDER = "cps:JetspeedPrincipalManagerProvider";
     public final static String CPS_PORTLET_APPLICATION_MANAGER = "cps:PAM";
     public final static String CPS_AUTHENTICATION_PROVIDER = "cps:AuthenticationProvider";
-    
+    public final static String CPS_CACHE_MONITOR = "cps:CacheMonitor";       
 }
\ No newline at end of file

Added: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/CacheMonitorState.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/CacheMonitorState.java?rev=773303&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/CacheMonitorState.java (added)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/CacheMonitorState.java Sun May 10 03:34:13 2009
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.cache;
+
+/**
+ * <p>
+ *  Individual cache information and state to provide to Jetspeed Cache Monitor
+ * </p>
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$
+ */
+public interface CacheMonitorState
+{
+    /**
+     * @return the name of the cache
+     */
+    String getCacheName();
+
+    /**
+     * @return the number of elements in the memory cache
+     */    
+    long getMemoryStoreSize();
+
+    /**
+     * @return the size of the memory store for this cache
+     */    
+    long getInMemorySize();
+    
+    /**
+     * @return the entire size of the cache including the number of elements in the memory store plus the number of elements in the disk store
+     */
+    long getSize();
+    
+    /**
+     * @return the number of elements in the disk store
+     */
+    long getDiskStoreSize();
+
+    /**
+     * @return the average time to retrieve a cache element in milliseconds
+     */
+    float getAverageGetTime();
+    
+    /**
+     * @return the number of times a requested item was found in the cache.
+     */
+    long getCacheHits();
+
+    /**
+     * @return the number of times a requested element was not found in the cache
+     */    
+    long getCacheMisses();
+    
+    /**
+     * @return the number of cache evictions, since the cache was created, or statistics were cleared
+     */    
+    long getEvictionCount();
+    
+    /**
+     * @return the number of times a requested item was found in memory 
+     */    
+    long getInMemoryHits();
+    
+    /**
+     * @return gets the number of elements stored in the cache. Caclulating this can be expensive. 
+     * Accordingly, this method will return three different values, depending on the statistics accuracy setting
+     */    
+    long getObjectCount();
+    
+    /**
+     * @return the number of times a requested element was not found in the cache
+     */    
+    long getOnDiskHits();
+    
+    /**
+     * @return get configured maximum elements in memory
+     */
+    long getMaxElementsInMemory();
+
+    /**
+     * @return get configured maximum elements on disk
+     */
+    long getMaxElementsOnDisk();
+    
+    /**
+     * @return get configured time to idle in seconds before expiring
+     */
+    long getTimeToIdle();
+
+    /**
+     * @return get configured time to live in seconds before expiring
+     */
+    long getTimeToLive();
+}
+ 
\ No newline at end of file

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/CacheMonitorState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/CacheMonitorState.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/JetspeedCacheMonitor.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/JetspeedCacheMonitor.java?rev=773303&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/JetspeedCacheMonitor.java (added)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/JetspeedCacheMonitor.java Sun May 10 03:34:13 2009
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.cache;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  Monitor active Jetspeed Caches by retrieving snapshots of cache statistics, recalculating cache statistics, and resetting the cache statistics
+ *  Warning, the methods calculateStatistics can be computationally expensive 
+ * </p>
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$
+ */
+public interface JetspeedCacheMonitor
+{
+    /**
+     * Retrieve a snapshot of all cache states and statistics
+     * 
+     * @return a list of cache states
+     */
+    List<CacheMonitorState> snapshotStatistics();
+    
+    /**
+     * Retrieve a snapshot of a single cache states and statistics without performing expensive object count calculations
+     * 
+     * @param cacheName the name of the cache
+     * @return a single cache statistics snapshot
+     */    
+    CacheMonitorState snapshotStatistics(String cacheName);
+    
+    /**
+     * Reset the statistics for all caches
+     */
+    void resetStatistics();
+    
+    /**
+     * Reset the statistics for the given cache
+     * 
+     * @param cacheName the name of the cache
+     */
+    void resetStatistics(String cacheName);
+    
+    /**
+     * Recalculate the statistics for all caches, including cache size calculations. This may take considerable amount of time depending on the size of the caches.
+     * @return new statistics list freshly calculated
+     */
+    List<CacheMonitorState> calculateStatistics();
+    
+    /**
+     * Recalculate the statistics for the given cache, including cache size calculations. This may take considerable amount of time depending on the size of the caches.
+     * 
+     * @param cacheName the name of the cache
+     * @return new statistics freshly calculated
+     */
+    CacheMonitorState calculateStatistics(String cacheName);    
+    
+}
+ 
\ No newline at end of file

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/JetspeedCacheMonitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/JetspeedCacheMonitor.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/cache.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/cache.xml?rev=773303&r1=773302&r2=773303&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/cache.xml (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/cache.xml Sun May 10 03:34:13 2009
@@ -29,6 +29,13 @@
         <meta key="j2:cat" value="default or cache"/>
         <property name="configLocation" ref="cacheManagerConfig"/>
     </bean>
+
+    <bean id="org.apache.jetspeed.cache.CacheMonitor" class="org.apache.jetspeed.cache.impl.JetspeedCacheMonitorImpl">
+        <meta key="j2:cat" value="default or cache"/>
+        <constructor-arg index="0">
+            <ref bean="cacheManager" />
+        </constructor-arg>
+    </bean>
     
     <!-- Page File Cache -->
     <bean id="PageFileCache" class="org.apache.jetspeed.cache.file.FileCache" init-method="startFileScanner"

Modified: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-services.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-services.xml?rev=773303&r1=773302&r2=773303&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-services.xml (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-services.xml Sun May 10 03:34:13 2009
@@ -132,6 +132,9 @@
         <entry key="AuthenticationProvider">
         	<ref bean="org.apache.jetspeed.security.AuthenticationProvider" />
         </entry>
+        <entry key="CacheMonitor">
+        	<ref bean="org.apache.jetspeed.cache.CacheMonitor" />
+        </entry>
         <!--<entry key="SecurityAttributesProvider">
           <ref bean="org.apache.jetspeed.security.attributes.SecurityAttributesProvider" />
           </entry>-->



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