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 2013/12/04 14:22:27 UTC

svn commit: r1547795 - in /manifoldcf/branches/CONNECTORS-781/framework: authority-servlet/src/main/java/org/apache/manifoldcf/authorityservlet/ pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/

Author: kwright
Date: Wed Dec  4 13:22:26 2013
New Revision: 1547795

URL: http://svn.apache.org/r1547795
Log:
Hook up mapping pool everywhere.

Modified:
    manifoldcf/branches/CONNECTORS-781/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservlet/UserACLServlet.java
    manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java
    manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/ManifoldCF.java
    manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingRequest.java
    manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java

Modified: manifoldcf/branches/CONNECTORS-781/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservlet/UserACLServlet.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservlet/UserACLServlet.java?rev=1547795&r1=1547794&r2=1547795&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservlet/UserACLServlet.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservlet/UserACLServlet.java Wed Dec  4 13:22:26 2013
@@ -268,8 +268,7 @@ public class UserACLServlet extends Http
           identifyingString = connectionName;
 
         // Create a request
-        MappingRequest mr = new MappingRequest(
-          thisConnection.getClassName(),identifyingString,thisConnection.getConfigParams(),thisConnection.getMaxConnections());
+        MappingRequest mr = new MappingRequest(thisConnection,identifyingString);
         mappingRequests.put(mapperDesc, mr);
 
         // Either start up a thread, or just fire it off immediately.

Modified: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java?rev=1547795&r1=1547794&r2=1547795&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java Wed Dec  4 13:22:26 2013
@@ -53,6 +53,7 @@ public class IdleCleanupThread extends T
       IThreadContext threadContext = ThreadContextFactory.make();
       ICacheManager cacheManager = CacheManagerFactory.make(threadContext);
       IAuthorityConnectorPool authorityConnectorPool = AuthorityConnectorPoolFactory.make(threadContext);
+      IMappingConnectorPool mappingConnectorPool = MappingConnectorPoolFactory.make(threadContext);
       
       // Loop
       while (true)
@@ -62,6 +63,7 @@ public class IdleCleanupThread extends T
         {
           // Do the cleanup
           authorityConnectorPool.pollAllConnectors();
+          mappingConnectorPool.pollAllConnectors();
           cacheManager.expireObjects(System.currentTimeMillis());
           
           // Sleep for the retry interval.
@@ -73,7 +75,7 @@ public class IdleCleanupThread extends T
             break;
 
           // Log it, but keep the thread alive
-          Logging.authorityService.error("Exception tossed",e);
+          Logging.authorityService.error("Exception tossed: "+e.getMessage(),e);
 
           if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR)
           {

Modified: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/ManifoldCF.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/ManifoldCF.java?rev=1547795&r1=1547794&r2=1547795&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/ManifoldCF.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/ManifoldCF.java Wed Dec  4 13:22:26 2013
@@ -96,7 +96,7 @@ public class ManifoldCF extends org.apac
     }
     try
     {
-      MappingConnectorFactory.closeAllConnectors(tc);
+      MappingConnectorPoolFactory.make(tc).closeAllConnectors();
     }
     catch (ManifoldCFException e)
     {
@@ -271,7 +271,7 @@ public class ManifoldCF extends org.apac
     AuthorityConnectorPoolFactory.make(threadContext).flushUnusedConnectors();
     numAuthCheckThreads = 0;
     requestQueue = null;
-    MappingConnectorFactory.flushUnusedConnectors(threadContext);
+    MappingConnectorPoolFactory.make(threadContext).flushUnusedConnectors();
     numMappingThreads = 0;
     mappingRequestQueue = null;
   }

Modified: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingRequest.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingRequest.java?rev=1547795&r1=1547794&r2=1547795&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingRequest.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingRequest.java Wed Dec  4 13:22:26 2013
@@ -32,10 +32,8 @@ public class MappingRequest
 
   // This is where the request data actually lives
   protected String userID;
-  protected final String className;
+  protected final IMappingConnection mappingConnection;
   protected final String identifyingString;
-  protected final ConfigParams configParameters;
-  protected final int maxConnections;
 
   // These are the possible results of the request
   protected boolean answerComplete = false;
@@ -44,12 +42,10 @@ public class MappingRequest
 
   /** Construct the request, and record the question.
   */
-  public MappingRequest(String className, String identifyingString, ConfigParams configParameters, int maxConnections)
+  public MappingRequest(IMappingConnection mappingConnection, String identifyingString)
   {
-    this.className = className;
+    this.mappingConnection = mappingConnection;
     this.identifyingString = identifyingString;
-    this.configParameters = configParameters;
-    this.maxConnections = maxConnections;
   }
 
   /** Set the user ID we'll be using */
@@ -64,10 +60,11 @@ public class MappingRequest
     return userID;
   }
   
-  /** Get the class name */
-  public String getClassName()
+  /** Get the mapping connection.
+  */
+  public IMappingConnection getMappingConnection()
   {
-    return className;
+    return mappingConnection;
   }
 
   /** Get the identifying string, to pass back to the user if there was a problem */
@@ -76,18 +73,6 @@ public class MappingRequest
     return identifyingString;
   }
 
-  /** Get the configuration parameters */
-  public ConfigParams getConfigurationParams()
-  {
-    return configParameters;
-  }
-
-  /** Get the maximum number of connections */
-  public int getMaxConnections()
-  {
-    return maxConnections;
-  }
-
   /** Wait for an auth request to be complete.
   */
   public void waitForComplete()

Modified: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java?rev=1547795&r1=1547794&r2=1547795&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java Wed Dec  4 13:22:26 2013
@@ -49,107 +49,114 @@ public class MappingThread extends Threa
   {
     // Create a thread context object.
     IThreadContext threadContext = ThreadContextFactory.make();
-
-    // Loop
-    while (true)
+    try
     {
-      // Do another try/catch around everything in the loop
-      try
+      IMappingConnectorPool mappingConnectorPool = MappingConnectorPoolFactory.make(threadContext);
+      // Loop
+      while (true)
       {
-        if (Thread.currentThread().isInterrupted())
-          throw new ManifoldCFException("Interrupted",ManifoldCFException.INTERRUPTED);
+        // Do another try/catch around everything in the loop
+        try
+        {
+          if (Thread.currentThread().isInterrupted())
+            throw new ManifoldCFException("Interrupted",ManifoldCFException.INTERRUPTED);
 
-        // Wait for a request.
-        MappingRequest theRequest = requestQueue.getRequest();
+          // Wait for a request.
+          MappingRequest theRequest = requestQueue.getRequest();
 
-        // Try to fill the request before going back to sleep.
-        if (Logging.authorityService.isDebugEnabled())
-        {
-          Logging.authorityService.debug(" Calling mapping connector class '"+theRequest.getClassName()+"'");
-        }
+          // Try to fill the request before going back to sleep.
+          if (Logging.authorityService.isDebugEnabled())
+          {
+            Logging.authorityService.debug(" Calling mapping connector class '"+theRequest.getMappingConnection().getClassName()+"'");
+          }
 
-	String outputUserID = null;
-        Throwable exception = null;
+          String outputUserID = null;
+          Throwable exception = null;
 
-        // Only try a mapping if we have a user to map...
-        if (theRequest.getUserID() != null)
-        {
-          try
+          // Only try a mapping if we have a user to map...
+          if (theRequest.getUserID() != null)
           {
-            IMappingConnector connector = MappingConnectorFactory.grab(threadContext,
-              theRequest.getClassName(),
-              theRequest.getConfigurationParams(),
-              theRequest.getMaxConnections());
             try
             {
-              if (connector == null)
-                exception = new ManifoldCFException("Mapping connector "+theRequest.getClassName()+" is not registered.");
-              else
+              IMappingConnector connector = mappingConnectorPool.grab(theRequest.getMappingConnection());
+              try
               {
-                // Do the mapping
-                try
+                if (connector == null)
+                  exception = new ManifoldCFException("Mapping connector "+theRequest.getMappingConnection().getClassName()+" is not registered.");
+                else
                 {
-                  outputUserID = connector.mapUser(theRequest.getUserID());
-                }
-                catch (ManifoldCFException e)
-                {
-                  if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-                    throw e;
-                  Logging.authorityService.warn("Mapping error: "+e.getMessage(),e);
-                }
+                  // Do the mapping
+                  try
+                  {
+                    outputUserID = connector.mapUser(theRequest.getUserID());
+                  }
+                  catch (ManifoldCFException e)
+                  {
+                    if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+                      throw e;
+                    Logging.authorityService.warn("Mapping error: "+e.getMessage(),e);
+                  }
 
+                }
+              }
+              finally
+              {
+                mappingConnectorPool.release(connector);
               }
             }
-            finally
+            catch (ManifoldCFException e)
             {
-              MappingConnectorFactory.release(connector);
+              if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+                throw e;
+              Logging.authorityService.warn("Mapping connection exception: "+e.getMessage(),e);
+              exception = e;
+            }
+            catch (Throwable e)
+            {
+              Logging.authorityService.warn("Mapping connection error: "+e.getMessage(),e);
+              exception = e;
             }
           }
-          catch (ManifoldCFException e)
-          {
-            if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-              throw e;
-            Logging.authorityService.warn("Mapping connection exception: "+e.getMessage(),e);
-            exception = e;
-          }
-          catch (Throwable e)
-          {
-            Logging.authorityService.warn("Mapping connection error: "+e.getMessage(),e);
-            exception = e;
-          }
-        }
 
-        // The request is complete
-        theRequest.completeRequest(outputUserID, exception);
+          // The request is complete
+          theRequest.completeRequest(outputUserID, exception);
 
-        // Repeat, and only go to sleep if there are no more requests.
-      }
-      catch (ManifoldCFException e)
-      {
-        if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-          break;
+          // Repeat, and only go to sleep if there are no more requests.
+        }
+        catch (ManifoldCFException e)
+        {
+          if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+            break;
 
-        // Log it, but keep the thread alive
-        Logging.authorityService.error("Exception tossed: "+e.getMessage(),e);
+          // Log it, but keep the thread alive
+          Logging.authorityService.error("Exception tossed: "+e.getMessage(),e);
 
-        if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR)
+          if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR)
+          {
+            // Shut the whole system down!
+            System.exit(1);
+          }
+
+        }
+        catch (InterruptedException e)
         {
-          // Shut the whole system down!
-          System.exit(1);
+          // We're supposed to quit
+          break;
+        }
+        catch (Throwable e)
+        {
+          // 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.getMessage(),e);
       }
     }
+    catch (ManifoldCFException e)
+    {
+      // Severe error on initialization
+      System.err.println("Authority service mapping thread could not start - shutting down");
+      Logging.authorityService.fatal("MappingThread initialization error tossed: "+e.getMessage(),e);
+      System.exit(-300);
+    }
   }
 
 }