jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppakul...@apache.org
Subject svn commit: r631606 - /jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java
Date Wed, 27 Feb 2008 14:48:07 GMT
Author: ppakulski
Date: Wed Feb 27 06:48:04 2008
New Revision: 631606

URL: http://svn.apache.org/viewvc?rev=631606&view=rev
Log:
JCR-1429: CacheManager interval between recalculation of cache sizes should be configurable
(JCR-1112 backport)

Modified:
    jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java

Modified: jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java?rev=631606&r1=631605&r2=631606&view=diff
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java
Wed Feb 27 06:48:04 2008
@@ -53,8 +53,8 @@
     /** The set of caches (weakly referenced). */
     private WeakHashMap caches = new WeakHashMap();
 
-    /** Rebalance the caches each ... milliseconds at most. */
-    private static final int SLEEP = 1000;
+    /** The default minimum resize interval (in ms). */
+    private static final int DEFAULT_MIN_RESIZE_INTERVAL = 1000;
 
     /** The size of a big object, to detect if a cache is full or not. */
     private static final int BIG_OBJECT_SIZE = 16 * 1024;
@@ -67,9 +67,12 @@
 
     /** The maximum memory per cache (unless, there is some unused memory). */
     private long maxMemoryPerCache = DEFAULT_MAX_MEMORY_PER_CACHE;
-
-    /** The last time the caches where resized. */
-    private volatile long nextResize = System.currentTimeMillis() + SLEEP;
+    
+    /** The minimum resize interval time */
+    private long minResizeInterval = DEFAULT_MIN_RESIZE_INTERVAL;
+     
+        /** The last time the caches where resized. */
+    private volatile long nextResize = System.currentTimeMillis() + DEFAULT_MIN_RESIZE_INTERVAL;
 
     
     public long getMaxMemory() {
@@ -96,6 +99,13 @@
         this.minMemoryPerCache = minMemoryPerCache;
     }
     
+    public long getMinResizeInterval() {
+        return minResizeInterval;
+    }
+
+    public void setMinResizeInterval(long minResizeInterval) {
+        this.minResizeInterval = minResizeInterval;
+    }
 
     /**
      * After one of the caches is accessed a number of times, this method is called.
@@ -112,9 +122,9 @@
             if (now < nextResize) {
                 return;
             }
-            nextResize = now + SLEEP;
+            nextResize = now + minResizeInterval;
             resizeAll();
-            nextResize = System.currentTimeMillis() + SLEEP;
+            nextResize = System.currentTimeMillis() + minResizeInterval;
         }
     }
 



Mime
View raw message