jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1497714 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: api/jmx/CacheStatsMBean.java cache/CacheStats.java
Date Fri, 28 Jun 2013 10:26:27 GMT
Author: chetanm
Date: Fri Jun 28 10:26:27 2013
New Revision: 1497714

URL: http://svn.apache.org/r1497714
Log:
OAK-863 - Enable stats for various caches used in Oak by default

Adding support for resetting cache stats

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/jmx/CacheStatsMBean.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/CacheStats.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/jmx/CacheStatsMBean.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/jmx/CacheStatsMBean.java?rev=1497714&r1=1497713&r2=1497714&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/jmx/CacheStatsMBean.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/jmx/CacheStatsMBean.java
Fri Jun 28 10:26:27 2013
@@ -112,6 +112,11 @@ public interface CacheStatsMBean {
      */
     long getElementCount();
 
+    /**
+     * The maximum weight of entries the cache may contain.
+     * @return  the maximum total weight of entries the cache may contain
+     */
+    long getMaxTotalWeight();
 
     /**
      * Total weight of the complete cache. Depending on implementation it might be the amount
@@ -122,13 +127,12 @@ public interface CacheStatsMBean {
     long estimateCurrentWeight();
 
     /**
-     * The maximum weight of entries the cache may contain.
-     * @return  the maximum total weight of entries the cache may contain
+     * Gathers the stats of the cache for logging.
      */
-    long getMaxTotalWeight();
+    String cacheInfoAsString();
 
     /**
-     * Gathers the stats of the cache for logging.
+     * Reset the cache stats
      */
-    String cacheInfoAsString();
+    void resetCache();
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/CacheStats.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/CacheStats.java?rev=1497714&r1=1497713&r2=1497714&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/CacheStats.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/CacheStats.java
Fri Jun 28 10:26:27 2013
@@ -31,6 +31,8 @@ public class CacheStats implements Cache
     private final Weigher weigher;
     private final long maxWeight;
     private final String name;
+    private com.google.common.cache.CacheStats statsSnapShot =
+            new com.google.common.cache.CacheStats(0,0,0,0,0,0);
 
     public CacheStats(Cache cache, String name, Weigher weigher, long maxWeight) {
         this.cache = cache;
@@ -122,6 +124,13 @@ public class CacheStats implements Cache
     }
 
     @Override
+    public synchronized void resetCache(){
+        //Cache stats cannot be rest at Guava level. Instead we
+        //take a snapshot and then subtract it from future stats calls
+        statsSnapShot = cache.stats();
+    }
+
+    @Override
     public String cacheInfoAsString() {
         return Objects.toStringHelper("CacheStats")
                 .add("hitCount", getHitCount())
@@ -146,7 +155,7 @@ public class CacheStats implements Cache
     }
 
     private com.google.common.cache.CacheStats stats() {
-        return cache.stats();
+        return cache.stats().minus(statsSnapShot);
     }
 
     /**



Mime
View raw message