You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by th...@apache.org on 2014/12/01 14:44:40 UTC

svn commit: r1642682 - in /jackrabbit/oak: branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/ trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/

Author: thomasm
Date: Mon Dec  1 13:44:40 2014
New Revision: 1642682

URL: http://svn.apache.org/r1642682
Log:
OAK-2309 Persistent cache: config option for autoCompact

Modified:
    jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/PersistentCache.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/PersistentCache.java

Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/PersistentCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/PersistentCache.java?rev=1642682&r1=1642681&r2=1642682&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/PersistentCache.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/PersistentCache.java Mon Dec  1 13:44:40 2014
@@ -58,8 +58,9 @@ public class PersistentCache {
     private MVStore readStore;
     private int maxSizeMB = 1024;
     private int readGeneration = -1;
-    private int writeGeneration = 0;
+    private int writeGeneration;
     private long maxBinaryEntry = 1024 * 1024;
+    private int autoCompact = 50;
     
     public PersistentCache(String url) {
         LOG.info("start version 1");
@@ -89,6 +90,8 @@ public class PersistentCache {
                 maxSizeMB = Integer.parseInt(p.split("=")[1]);
             } else if (p.startsWith("binary=")) {
                 maxBinaryEntry = Long.parseLong(p.split("=")[1]);
+            } else if (p.startsWith("autoCompact=")) {
+                autoCompact = Integer.parseInt(p.split("=")[1]);
             }
         }
         this.directory = dir;
@@ -108,7 +111,7 @@ public class PersistentCache {
         File[] list = dr.listFiles();
         TreeSet<Integer> generations = new TreeSet<Integer>();
         if (list != null) {
-            for(File f : list) {
+            for (File f : list) {
                 String fn = f.getName();
                 if (fn.startsWith(FILE_PREFIX) && fn.endsWith(FILE_SUFFIX)) {
                     String g = fn.substring(FILE_PREFIX.length(), fn.indexOf(FILE_SUFFIX));
@@ -160,6 +163,9 @@ public class PersistentCache {
         if (maxSizeMB < 10) {
             builder.cacheSize(maxSizeMB);
         }
+        if (autoCompact >= 0) {
+            builder.autoCompactFillRate(autoCompact);
+        }
         builder.backgroundExceptionHandler(new Thread.UncaughtExceptionHandler() {
             @Override
             public void uncaughtException(Thread t, Throwable e) {
@@ -300,13 +306,12 @@ public class PersistentCache {
         return maxBinaryEntry;
     }
 
-    static interface GenerationCache {
+    interface GenerationCache {
 
         void addGeneration(int writeGeneration, boolean b);
 
         void removeGeneration(int oldReadGeneration);
         
-        
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/PersistentCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/PersistentCache.java?rev=1642682&r1=1642681&r2=1642682&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/PersistentCache.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/PersistentCache.java Mon Dec  1 13:44:40 2014
@@ -58,8 +58,9 @@ public class PersistentCache {
     private MVStore readStore;
     private int maxSizeMB = 1024;
     private int readGeneration = -1;
-    private int writeGeneration = 0;
+    private int writeGeneration;
     private long maxBinaryEntry = 1024 * 1024;
+    private int autoCompact = 50;
     
     public PersistentCache(String url) {
         LOG.info("start version 1");
@@ -89,6 +90,8 @@ public class PersistentCache {
                 maxSizeMB = Integer.parseInt(p.split("=")[1]);
             } else if (p.startsWith("binary=")) {
                 maxBinaryEntry = Long.parseLong(p.split("=")[1]);
+            } else if (p.startsWith("autoCompact=")) {
+                autoCompact = Integer.parseInt(p.split("=")[1]);
             }
         }
         this.directory = dir;
@@ -108,7 +111,7 @@ public class PersistentCache {
         File[] list = dr.listFiles();
         TreeSet<Integer> generations = new TreeSet<Integer>();
         if (list != null) {
-            for(File f : list) {
+            for (File f : list) {
                 String fn = f.getName();
                 if (fn.startsWith(FILE_PREFIX) && fn.endsWith(FILE_SUFFIX)) {
                     String g = fn.substring(FILE_PREFIX.length(), fn.indexOf(FILE_SUFFIX));
@@ -160,6 +163,9 @@ public class PersistentCache {
         if (maxSizeMB < 10) {
             builder.cacheSize(maxSizeMB);
         }
+        if (autoCompact >= 0) {
+            builder.autoCompactFillRate(autoCompact);
+        }
         builder.backgroundExceptionHandler(new Thread.UncaughtExceptionHandler() {
             @Override
             public void uncaughtException(Thread t, Throwable e) {
@@ -300,13 +306,12 @@ public class PersistentCache {
         return maxBinaryEntry;
     }
 
-    static interface GenerationCache {
+    interface GenerationCache {
 
         void addGeneration(int writeGeneration, boolean b);
 
         void removeGeneration(int oldReadGeneration);
         
-        
     }
 
 }