You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2011/04/16 23:06:31 UTC

svn commit: r1094054 - in /incubator/lcf/branches/CONNECTORS-32: ./ framework/core/src/main/java/org/apache/manifoldcf/core/cachemanager/ framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/ framework/pull-agent/src/main/java/or...

Author: kwright
Date: Sat Apr 16 21:06:31 2011
New Revision: 1094054

URL: http://svn.apache.org/viewvc?rev=1094054&view=rev
Log:
Merge in CONNECTORS-182 fixes.

Modified:
    incubator/lcf/branches/CONNECTORS-32/   (props changed)
    incubator/lcf/branches/CONNECTORS-32/CHANGES.txt
    incubator/lcf/branches/CONNECTORS-32/framework/core/src/main/java/org/apache/manifoldcf/core/cachemanager/CacheManager.java
    incubator/lcf/branches/CONNECTORS-32/framework/core/src/main/java/org/apache/manifoldcf/core/cachemanager/GeneralCache.java
    incubator/lcf/branches/CONNECTORS-32/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java
    incubator/lcf/branches/CONNECTORS-32/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/IdleCleanupThread.java

Propchange: incubator/lcf/branches/CONNECTORS-32/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Apr 16 21:06:31 2011
@@ -1,3 +1,3 @@
 /incubator/lcf/branches/CONNECTORS-151-branch:1063444-1071206
 /incubator/lcf/branches/CONNECTORS-160-branch:1071241-1071534
-/incubator/lcf/trunk:1092566,1092568,1092631,1092805,1092813
+/incubator/lcf/trunk:1092566,1092568,1092631,1092805,1092813,1094053

Modified: incubator/lcf/branches/CONNECTORS-32/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-32/CHANGES.txt?rev=1094054&r1=1094053&r2=1094054&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-32/CHANGES.txt (original)
+++ incubator/lcf/branches/CONNECTORS-32/CHANGES.txt Sat Apr 16 21:06:31 2011
@@ -7,6 +7,10 @@ authority connector, LiveLink authority 
 connector, and Documentum authority connector.
 (Shinichiro Abe, Karl Wright)
 
+CONNECTORS-182: Install timed expiration of cached objects, which
+was not hooked up to the idle cleanup architecture.
+(Karl Wright)
+
 CONNECTORS-181: Fix the way timed expiration works to agree with
 the description, and pass in a current time parameter to make it
 work readily for continuous renewal.

Modified: incubator/lcf/branches/CONNECTORS-32/framework/core/src/main/java/org/apache/manifoldcf/core/cachemanager/CacheManager.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-32/framework/core/src/main/java/org/apache/manifoldcf/core/cachemanager/CacheManager.java?rev=1094054&r1=1094053&r2=1094054&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-32/framework/core/src/main/java/org/apache/manifoldcf/core/cachemanager/CacheManager.java (original)
+++ incubator/lcf/branches/CONNECTORS-32/framework/core/src/main/java/org/apache/manifoldcf/core/cachemanager/CacheManager.java Sat Apr 16 21:06:31 2011
@@ -430,6 +430,15 @@ public class CacheManager implements ICa
     {
       Logging.cache.debug(" Object '"+objectDescription.getCriticalSectionName()+"' exists locally; checking if local copy is valid");
     }
+
+    // See if the object's attached expiration is before the current time.
+    long expireTime = cache.getObjectExpirationTime(objectDescription);
+    if (expireTime != -1L && expireTime <= handle.getLookupTime())
+    {
+      // Blow away the entry in cache, since it has expired
+      cache.deleteObject(objectDescription);
+      return null;
+    }
     
     // Before we conclude that the object is found, if we are on a multi-JVM environment we MUST check
     // the object's timestamp!!!  We check it against the invalidation key file timestamps for the object.

Modified: incubator/lcf/branches/CONNECTORS-32/framework/core/src/main/java/org/apache/manifoldcf/core/cachemanager/GeneralCache.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-32/framework/core/src/main/java/org/apache/manifoldcf/core/cachemanager/GeneralCache.java?rev=1094054&r1=1094053&r2=1094054&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-32/framework/core/src/main/java/org/apache/manifoldcf/core/cachemanager/GeneralCache.java (original)
+++ incubator/lcf/branches/CONNECTORS-32/framework/core/src/main/java/org/apache/manifoldcf/core/cachemanager/GeneralCache.java Sat Apr 16 21:06:31 2011
@@ -80,6 +80,18 @@ public class GeneralCache
     return o.getKeys();
   }
 
+  /** Get the expiration time for an object in the cache.
+  *@param objectDescription is the object's unique identifier.
+  *@return the expiration time (-1L means none).
+  */
+  public synchronized long getObjectExpirationTime(Object objectDescription)
+  {
+    ObjectRecord o = hashtable.lookup(objectDescription);
+    if (o == null)
+      return -1L;
+    return o.getObjectExpiration();
+  }
+
   /** Delete a record from the cache.
   *@param objectDescription is the unique description.
   */

Modified: incubator/lcf/branches/CONNECTORS-32/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-32/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java?rev=1094054&r1=1094053&r2=1094054&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-32/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java (original)
+++ incubator/lcf/branches/CONNECTORS-32/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java Sat Apr 16 21:06:31 2011
@@ -47,47 +47,59 @@ public class IdleCleanupThread extends T
 
   public void run()
   {
-    // Create a thread context object.
-    IThreadContext threadContext = ThreadContextFactory.make();
-
-    // Loop
-    while (true)
+    try
     {
-      // Do another try/catch around everything in the loop
-      try
+      // Create a thread context object.
+      IThreadContext threadContext = ThreadContextFactory.make();
+      ICacheManager cacheManager = CacheManagerFactory.make(threadContext);
+      
+      // Loop
+      while (true)
       {
-        // Do the cleanup
-        AuthorityConnectorFactory.pollAllConnectors(threadContext);
+        // Do another try/catch around everything in the loop
+        try
+        {
+          // Do the cleanup
+          AuthorityConnectorFactory.pollAllConnectors(threadContext);
+          cacheManager.expireObjects(System.currentTimeMillis());
+          
+          // Sleep for the retry interval.
+          ManifoldCF.sleep(15000L);
+        }
+        catch (ManifoldCFException e)
+        {
+          if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+            break;
 
-        // Sleep for the retry interval.
-        ManifoldCF.sleep(15000L);
-      }
-      catch (ManifoldCFException e)
-      {
-        if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-          break;
+          // Log it, but keep the thread alive
+          Logging.authorityService.error("Exception tossed",e);
 
-        // Log it, but keep the thread alive
-        Logging.authorityService.error("Exception tossed",e);
+          if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR)
+          {
+            // Shut the whole system down!
+            System.exit(1);
+          }
 
-        if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR)
+        }
+        catch (InterruptedException e)
+        {
+          // We're supposed to quit
+          break;
+        }
+        catch (Throwable e)
         {
-          // Shut the whole system down!
-          System.exit(1);
+          // A more severe error - but stay alive
+          Logging.authorityService.fatal("Error tossed: "+e.getMessage(),e);
         }
-
-      }
-      catch (InterruptedException e)
-      {
-        // We're supposed to quit
-        break;
-      }
-      catch (Throwable e)
-      {
-        // A more severe error - but stay alive
-        Logging.authorityService.fatal("Error tossed",e);
       }
     }
+    catch (Throwable e)
+    {
+      // Severe error on initialization
+      System.err.println("Authority service idle cleanup could not start - shutting down");
+      Logging.authorityService.fatal("IdleCleanupThread initialization error tossed: "+e.getMessage(),e);
+      System.exit(-300);
+    }
   }
 
 }

Modified: incubator/lcf/branches/CONNECTORS-32/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/IdleCleanupThread.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-32/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/IdleCleanupThread.java?rev=1094054&r1=1094053&r2=1094054&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-32/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/IdleCleanupThread.java (original)
+++ incubator/lcf/branches/CONNECTORS-32/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/IdleCleanupThread.java Sat Apr 16 21:06:31 2011
@@ -52,7 +52,9 @@ public class IdleCleanupThread extends T
     {
       // Create a thread context object.
       IThreadContext threadContext = ThreadContextFactory.make();
-
+      // Get the cache handle.
+      ICacheManager cacheManager = CacheManagerFactory.make(threadContext);
+      
       // Loop
       while (true)
       {
@@ -62,7 +64,8 @@ public class IdleCleanupThread extends T
           // Do the cleanup
           RepositoryConnectorFactory.pollAllConnectors(threadContext);
           OutputConnectorFactory.pollAllConnectors(threadContext);
-
+          cacheManager.expireObjects(System.currentTimeMillis());
+          
           // Sleep for the retry interval.
           ManifoldCF.sleep(15000L);
         }