jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1499658 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: cache/CacheStats.java plugins/mongomk/MongoMK.java
Date Thu, 04 Jul 2013 05:37:24 GMT
Author: chetanm
Date: Thu Jul  4 05:37:23 2013
New Revision: 1499658

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

-- Enhancing CacheStats.toString
-- Using a loader for Node Children cache to get an estimate of time taken to load children
as part of stats

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/CacheStats.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java

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=1499658&r1=1499657&r2=1499658&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
Thu Jul  4 05:37:23 2013
@@ -152,7 +152,7 @@ public class CacheStats implements Cache
                 .add("loadSuccessCount", getLoadSuccessCount())
                 .add("loadExceptionCount", getLoadExceptionCount())
                 .add("totalLoadTime", timeInWords(getTotalLoadTime()))
-                .add("averageLoadPenalty (nanos)", getAverageLoadPenalty())
+                .add("averageLoadPenalty (nanos)", String.format("%1.2f", getAverageLoadPenalty()))
                 .add("evictionCount", getEvictionCount())
                 .add("elementCount", getElementCount())
                 .add("totalWeight", humanReadableByteCount(estimateCurrentWeight(), true))

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java?rev=1499658&r1=1499657&r2=1499658&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
Thu Jul  4 05:37:23 2013
@@ -601,16 +601,24 @@ public class MongoMK implements MicroKer
         return includeRevision(revision, readRevision);
     }
 
-    public Children getChildren(String path, Revision rev, int limit) {
+    public Children getChildren(final String path, final Revision rev, final int limit) 
throws MicroKernelException{
         checkRevisionAge(rev, path);
         String key = path + "@" + rev;
-        Children children = nodeChildrenCache.getIfPresent(key);
-        if (children == null) {
-            children = readChildren(path, rev, limit);
-            if (children != null) {
-                nodeChildrenCache.put(key, children);
-            }
-        } else if (children.hasMore) {
+        Children children;
+        try {
+            children = nodeChildrenCache.get(key, new Callable<Children>() {
+                @Override
+                public Children call() throws Exception {
+                    return readChildren(path, rev, limit);
+                }
+            });
+        } catch (ExecutionException e) {
+            throw new MicroKernelException("Error occurred while fetching children nodes
for path "+path,e);
+        }
+
+        //In case the limit > cached children size and there are more child nodes
+        //available then refresh the cache
+        if (children.hasMore) {
             if (limit > children.children.size()) {
                 children = readChildren(path, rev, limit);
                 if (children != null) {



Mime
View raw message