portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r331199 - in /portals/jetspeed-2/trunk/components: file-cache/src/java/org/apache/jetspeed/cache/file/ file-cache/src/test/org/apache/jetspeed/cache/file/ page-manager/src/java/org/apache/jetspeed/page/psml/
Date Mon, 07 Nov 2005 04:34:59 GMT
Author: rwatler
Date: Sun Nov  6 20:34:55 2005
New Revision: 331199

URL: http://svn.apache.org/viewcvs?rev=331199&view=rev
Log:
Add FileCache.evictAll() to support CastorXmlPageManager.reset()

Modified:
    portals/jetspeed-2/trunk/components/file-cache/src/java/org/apache/jetspeed/cache/file/FileCache.java
    portals/jetspeed-2/trunk/components/file-cache/src/test/org/apache/jetspeed/cache/file/TestFileCache.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/psml/CastorXmlPageManager.java

Modified: portals/jetspeed-2/trunk/components/file-cache/src/java/org/apache/jetspeed/cache/file/FileCache.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/file-cache/src/java/org/apache/jetspeed/cache/file/FileCache.java?rev=331199&r1=331198&r2=331199&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/file-cache/src/java/org/apache/jetspeed/cache/file/FileCache.java
(original)
+++ portals/jetspeed-2/trunk/components/file-cache/src/java/org/apache/jetspeed/cache/file/FileCache.java
Sun Nov  6 20:34:55 2005
@@ -307,6 +307,49 @@
     }
 
     /**
+     * Evicts all entries
+     *
+     */
+    public void evictAll()        
+    {
+        synchronized (cache)
+        {
+            // evict all cache entries
+            List list = new LinkedList(cache.values());
+            for (Iterator it = list.iterator(); it.hasNext(); )
+            {
+                // evict cache entry
+                FileCacheEntry entry = (FileCacheEntry) it.next();
+                // notify that eviction will soon take place
+                for (Iterator lit = this.listeners.iterator(); lit.hasNext(); )
+                {
+                    FileCacheEventListener listener = 
+                        (FileCacheEventListener) lit.next();
+                    try
+                    {
+                        listener.evict(entry);
+                    }
+                    catch (Exception e1)
+                    {
+                        log.warn("Unable to evict cache entry.  "+e1.toString(), e1);
+                    }                                    
+                }
+                // remove from cache by key
+                String key = null;
+                try
+                {
+                    key = entry.getFile().getCanonicalPath();
+                }                    
+                catch (java.io.IOException e)
+                {
+                    log.error("Exception getting file path: ", e);
+                }
+                cache.remove(key);
+            }        
+        }
+    }
+
+    /**
      * Comparator function for sorting by last accessed during eviction
      *
      */

Modified: portals/jetspeed-2/trunk/components/file-cache/src/test/org/apache/jetspeed/cache/file/TestFileCache.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/file-cache/src/test/org/apache/jetspeed/cache/file/TestFileCache.java?rev=331199&r1=331198&r2=331199&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/file-cache/src/test/org/apache/jetspeed/cache/file/TestFileCache.java
(original)
+++ portals/jetspeed-2/trunk/components/file-cache/src/test/org/apache/jetspeed/cache/file/TestFileCache.java
Sun Nov  6 20:34:55 2005
@@ -113,6 +113,7 @@
             dumpCache(cache.getIterator());
 
             cache.addListener(this);
+
             // start the cache's scanner
             cache.startFileScanner();
 
@@ -143,13 +144,16 @@
 
             files[18].setLastModified(new Date().getTime());
 
-
             Thread.sleep(9000);
 
             assertNotNull(refreshedEntry);
             System.out.println("refreshed entry = " + refreshedEntry);
 
             cache.stopFileScanner();
+
+            // evict all from cache
+            cache.evictAll();
+            assertTrue(cache.getSize() == 0);
 
             removeTestFiles();
         }

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/psml/CastorXmlPageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/psml/CastorXmlPageManager.java?rev=331199&r1=331198&r2=331199&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/psml/CastorXmlPageManager.java
(original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/psml/CastorXmlPageManager.java
Sun Nov  6 20:34:55 2005
@@ -507,8 +507,12 @@
      */
     public void reset()
     {
-        // propagate
+        // propagate to super
         super.reset();
+
+        // evict all from file cache to force subsequent
+        // refreshs from persistent store
+        fileCache.evictAll();
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message