jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppakul...@apache.org
Subject svn commit: r592950 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java
Date Wed, 07 Nov 2007 23:29:21 GMT
Author: ppakulski
Date: Wed Nov  7 15:29:19 2007
New Revision: 592950

URL: http://svn.apache.org/viewvc?rev=592950&view=rev
Log:
public getter/setter for cache resize interval added to allow the interval programmatically
(JCR-1112 related)

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

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java?rev=592950&r1=592949&r2=592950&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java
Wed Nov  7 15:29:19 2007
@@ -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