jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shash...@apache.org
Subject svn commit: r1703096 - /jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/LocalCache.java
Date Tue, 15 Sep 2015 04:55:33 GMT
Author: shashank
Date: Tue Sep 15 04:55:32 2015
New Revision: 1703096

URL: http://svn.apache.org/r1703096
Log:
JCR-3907 Cache Misses statistics in LocalCache 

Fix. Added statistics logs at every 5 min

Modified:
    jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/LocalCache.java

Modified: jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/LocalCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/LocalCache.java?rev=1703096&r1=1703095&r2=1703096&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/LocalCache.java
(original)
+++ jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/LocalCache.java
Tue Sep 15 04:55:32 2015
@@ -29,6 +29,7 @@ import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
@@ -76,6 +77,11 @@ public class LocalCache {
     private volatile boolean purgeMode;
     
     private AsyncUploadCache asyncUploadCache;
+    
+    private AtomicLong cacheMissCounter = new AtomicLong();
+    
+    private AtomicLong cacheMissDuration = new AtomicLong();
+    
 
     /**
      * Build LRU cache of files located at 'path'. It uses lastModified property
@@ -247,12 +253,21 @@ public class LocalCache {
     public File getFileIfStored(String fileName) throws IOException {
         fileName = fileName.replace("\\", "/");
         File f = getFile(fileName);
+        long diff = (System.currentTimeMillis() - cacheMissDuration.get()) / 1000;
+        // logged at 5 minute interval minimum
+        if (diff > 5 * 60) {
+            LOG.info("local cache misses [{}] in [{}] sec", new Object[] {
+                cacheMissCounter.getAndSet(0), diff });
+            cacheMissDuration.set(System.currentTimeMillis());
+        }
+        
         // return file in purge mode = true and file present in asyncUploadCache
         // as asyncUploadCache's files will be not be deleted in cache purge.
         if (!f.exists() || (isInPurgeMode() && !asyncUploadCache.hasEntry(fileName,
false))) {
             LOG.debug(
                 "getFileIfStored returned: purgeMode=[{}], file=[{}] exists=[{}]",
                 new Object[] { isInPurgeMode(), f.getAbsolutePath(), f.exists() });
+            cacheMissCounter.incrementAndGet();
             return null;
         } else {
             // touch entry in LRU caches



Mime
View raw message