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 11:12:40 UTC

svn commit: r1547748 - 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 10:12:40 2013
New Revision: 1547748

URL: http://svn.apache.org/r1547748
Log:
Hook up authority connector pool

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/AuthCheckThread.java
    manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthRequest.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

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=1547748&r1=1547747&r2=1547748&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 10:12:40 2013
@@ -230,8 +230,7 @@ public class UserACLServlet extends Http
             identifyingString = thisConnection.getName();
           
           // Create a request
-          AuthRequest ar = new AuthRequest(
-            thisConnection.getClassName(),identifyingString,thisConnection.getConfigParams(),thisConnection.getMaxConnections());
+          AuthRequest ar = new AuthRequest(thisConnection,identifyingString);
           authRequests.put(thisConnection.getName(), ar);
           
           // We create an auth thread if there are prerequisites to meet.

Modified: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthCheckThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthCheckThread.java?rev=1547748&r1=1547747&r2=1547748&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthCheckThread.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthCheckThread.java Wed Dec  4 10:12:40 2013
@@ -50,114 +50,123 @@ public class AuthCheckThread extends Thr
   {
     // Create a thread context object.
     IThreadContext threadContext = ThreadContextFactory.make();
-
-    // Loop
-    while (true)
+    try
     {
-      // Do another try/catch around everything in the loop
-      try
+      // Create an authority connection pool object.
+      IAuthorityConnectorPool authorityConnectorPool = AuthorityConnectorPoolFactory.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.
-        AuthRequest theRequest = requestQueue.getRequest();
+          // Wait for a request.
+          AuthRequest theRequest = requestQueue.getRequest();
 
-        // Try to fill the request before going back to sleep.
-        if (Logging.authorityService.isDebugEnabled())
-        {
-          Logging.authorityService.debug(" Calling connector class '"+theRequest.getClassName()+"'");
-        }
+          // Try to fill the request before going back to sleep.
+          if (Logging.authorityService.isDebugEnabled())
+          {
+            Logging.authorityService.debug(" Calling connector class '"+theRequest.getAuthorityConnection().getClassName()+"'");
+          }
 
-        AuthorizationResponse response = null;
-        Throwable exception = null;
+          AuthorizationResponse response = null;
+          Throwable exception = null;
 
-        // Grab an authorization response only if there's a user
-        if (theRequest.getUserID() != null)
-        {
-          try
+          // Grab an authorization response only if there's a user
+          if (theRequest.getUserID() != null)
           {
-            IAuthorityConnector connector = AuthorityConnectorFactory.grab(threadContext,
-              theRequest.getClassName(),
-              theRequest.getConfigurationParams(),
-              theRequest.getMaxConnections());
-            // If this is null, we MUST treat this as an "unauthorized" condition!!
-            // We signal that by setting the exception value.
             try
             {
-              if (connector == null)
-                exception = new ManifoldCFException("Authority connector "+theRequest.getClassName()+" is not registered.");
-              else
+              IAuthorityConnector connector = authorityConnectorPool.grab(theRequest.getAuthorityConnection());
+              // If this is null, we MUST treat this as an "unauthorized" condition!!
+              // We signal that by setting the exception value.
+              try
               {
-                // Get the acl for the user
-                try
+                if (connector == null)
+                  exception = new ManifoldCFException("Authority connector "+theRequest.getAuthorityConnection().getClassName()+" is not registered.");
+                else
                 {
-                  response = connector.getAuthorizationResponse(theRequest.getUserID());
-                }
-                catch (ManifoldCFException e)
-                {
-                  if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-                    throw e;
-                  Logging.authorityService.warn("Authority error: "+e.getMessage(),e);
-                  response = AuthorityConnectorFactory.getDefaultAuthorizationResponse(threadContext,theRequest.getClassName(),theRequest.getUserID());
-                }
+                  // Get the acl for the user
+                  try
+                  {
+                    response = connector.getAuthorizationResponse(theRequest.getUserID());
+                  }
+                  catch (ManifoldCFException e)
+                  {
+                    if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+                      throw e;
+                    Logging.authorityService.warn("Authority error: "+e.getMessage(),e);
+                    response = AuthorityConnectorFactory.getDefaultAuthorizationResponse(threadContext,theRequest.getAuthorityConnection().getClassName(),theRequest.getUserID());
+                  }
 
+                }
+              }
+              finally
+              {
+                authorityConnectorPool.release(connector);
               }
             }
-            finally
+            catch (ManifoldCFException e)
             {
-              AuthorityConnectorFactory.release(connector);
+              if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+                throw e;
+              Logging.authorityService.warn("Authority connection exception: "+e.getMessage(),e);
+              response = AuthorityConnectorFactory.getDefaultAuthorizationResponse(threadContext,theRequest.getAuthorityConnection().getClassName(),theRequest.getUserID());
+              if (response == null)
+                exception = e;
+            }
+            catch (Throwable e)
+            {
+              Logging.authorityService.warn("Authority connection error: "+e.getMessage(),e);
+              response = AuthorityConnectorFactory.getDefaultAuthorizationResponse(threadContext,theRequest.getAuthorityConnection().getClassName(),theRequest.getUserID());
+              if (response == null)
+                exception = e;
             }
           }
-          catch (ManifoldCFException e)
-          {
-            if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-              throw e;
-            Logging.authorityService.warn("Authority connection exception: "+e.getMessage(),e);
-            response = AuthorityConnectorFactory.getDefaultAuthorizationResponse(threadContext,theRequest.getClassName(),theRequest.getUserID());
-            if (response == null)
-              exception = e;
-          }
-          catch (Throwable e)
-          {
-            Logging.authorityService.warn("Authority connection error: "+e.getMessage(),e);
-            response = AuthorityConnectorFactory.getDefaultAuthorizationResponse(threadContext,theRequest.getClassName(),theRequest.getUserID());
-            if (response == null)
-              exception = e;
-          }
-        }
 
-        // The request is complete
-        theRequest.completeRequest(response,exception);
+          // The request is complete
+          theRequest.completeRequest(response,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 auth check thread could not start - shutting down");
+      Logging.authorityService.fatal("AuthCheckThread initialization error tossed: "+e.getMessage(),e);
+      System.exit(-300);
+    }
   }
 
 }

Modified: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthRequest.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthRequest.java?rev=1547748&r1=1547747&r2=1547748&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthRequest.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthRequest.java Wed Dec  4 10:12:40 2013
@@ -32,10 +32,8 @@ public class AuthRequest
 
   // This is where the request data actually lives
   protected String userID;
-  protected final String className;
+  protected final IAuthorityConnection authorityConnection;
   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 AuthRequest
 
   /** Construct the request, and record the question.
   */
-  public AuthRequest(String className, String identifyingString, ConfigParams configParameters, int maxConnections)
+  public AuthRequest(IAuthorityConnection authorityConnection, String identifyingString)
   {
-    this.className = className;
+    this.authorityConnection = authorityConnection;
     this.identifyingString = identifyingString;
-    this.configParameters = configParameters;
-    this.maxConnections = maxConnections;
   }
 
   /** Set the user ID we'll be using */
@@ -64,10 +60,10 @@ public class AuthRequest
     return userID;
   }
 
-  /** Get the class name */
-  public String getClassName()
+  /** Get the authority connection */
+  public IAuthorityConnection getAuthorityConnection()
   {
-    return className;
+    return authorityConnection;
   }
 
   /** Get the identifying string, to pass back to the user if there was a problem */
@@ -76,18 +72,6 @@ public class AuthRequest
     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/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=1547748&r1=1547747&r2=1547748&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 10:12:40 2013
@@ -52,6 +52,7 @@ public class IdleCleanupThread extends T
       // Create a thread context object.
       IThreadContext threadContext = ThreadContextFactory.make();
       ICacheManager cacheManager = CacheManagerFactory.make(threadContext);
+      IAuthorityConnectorPool authorityConnectorPool = AuthorityConnectorPoolFactory.make(threadContext);
       
       // Loop
       while (true)
@@ -60,7 +61,7 @@ public class IdleCleanupThread extends T
         try
         {
           // Do the cleanup
-          AuthorityConnectorFactory.pollAllConnectors(threadContext);
+          authorityConnectorPool.pollAllConnectors();
           cacheManager.expireObjects(System.currentTimeMillis());
           
           // Sleep for the retry interval.

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=1547748&r1=1547747&r2=1547748&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 10:12:40 2013
@@ -248,7 +248,7 @@ public class ManifoldCF extends org.apac
     }
 
     // Release all authority connectors
-    AuthorityConnectorFactory.closeAllConnectors(threadContext);
+    AuthorityConnectorPoolFactory.make(threadContext).closeAllConnectors();
     numAuthCheckThreads = 0;
     requestQueue = null;
     MappingConnectorFactory.closeAllConnectors(threadContext);