Author: kwright
Date: Wed Dec  4 02:56:02 2013
New Revision: 1547696

URL: http://svn.apache.org/r1547696
Log:
Add authority pool thread-local object

Added:
    
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authorityconnectorpool/
    
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authorityconnectorpool/AuthorityConnectorPool.java
   (with props)
    
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorPoolFactory.java
   (with props)
    
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnectorPool.java
   (with props)
Modified:
    
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorFactory.java

Added: 
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authorityconnectorpool/AuthorityConnectorPool.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authorityconnectorpool/AuthorityConnectorPool.java?rev=1547696&view=auto
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authorityconnectorpool/AuthorityConnectorPool.java
 (added)
+++ 
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authorityconnectorpool/AuthorityConnectorPool.java
 Wed Dec  4 02:56:02 2013
@@ -0,0 +1,126 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.manifoldcf.authorities.authorityconnectorpool;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.authorities.interfaces.*;
+
+import java.util.*;
+import java.io.*;
+
+/** An implementation of IAuthorityConnectorPool.
+* Coordination and allocation among cluster members is managed within. 
+* These objects are thread-local, so do not share them among threads.
+*/
+public class AuthorityConnectorPool implements IAuthorityConnectorPool
+{
+  public static final String _rcsid = "@(#)$Id$";
+
+  // This implementation is a place-holder for the real one, which will likely 
fold in the pooling code
+  // as we strip it out of AuthorityConnectorFactory.
+
+  /** Thread context */
+  protected final IThreadContext threadContext;
+  
+  /** Constructor */
+  public AuthorityConnectorPool(IThreadContext threadContext)
+    throws ManifoldCFException
+  {
+    this.threadContext = threadContext;
+  }
+  
+  /** Get multiple authority connectors, all at once.  Do this in a particular 
order
+  * so that any connector exhaustion will not cause a deadlock.
+  *@param orderingKeys are the keys which determine in what order the 
connectors are obtained.
+  *@param authorityConnections are the connections to use the build the 
connector instances.
+  */
+  @Override
+  public IAuthorityConnector[] grabMultiple(String[] orderingKeys, 
IAuthorityConnection[] authorityConnections)
+    throws ManifoldCFException
+  {
+    // For now, use the AuthorityConnectorFactory method.  This will require 
us to extract info
+    // from each authority connection, however.
+    String[] classNames = new String[authorityConnections.length];
+    ConfigParams[] configInfos = new ConfigParams[authorityConnections.length];
+    int[] maxPoolSizes = new int[authorityConnections.length];
+    
+    for (int i = 0; i < authorityConnections.length; i++)
+    {
+      classNames[i] = authorityConnections[i].getClassName();
+      configInfos[i] = authorityConnections[i].getConfigParams();
+      maxPoolSizes[i] = authorityConnections[i].getMaxConnections();
+    }
+    return AuthorityConnectorFactory.grabMultiple(threadContext,
+      orderingKeys, classNames, configInfos, maxPoolSizes);
+  }
+
+  /** Get an authority connector.
+  * The connector is specified by an authority connection object.
+  *@param authorityConnection is the authority connection to base the 
connector instance on.
+  */
+  @Override
+  public IAuthorityConnector grab(IAuthorityConnection authorityConnection)
+    throws ManifoldCFException
+  {
+    return AuthorityConnectorFactory.grab(threadContext, 
authorityConnection.getClassName(),
+      authorityConnection.getConfigParams(), 
authorityConnection.getMaxConnections());
+  }
+
+  /** Release multiple authority connectors.
+  *@param connectors are the connector instances to release.
+  */
+  @Override
+  public void releaseMultiple(IAuthorityConnector[] connectors)
+    throws ManifoldCFException
+  {
+    AuthorityConnectorFactory.releaseMultiple(connectors);
+  }
+
+  /** Release an authority connector.
+  *@param connector is the connector to release.
+  */
+  @Override
+  public void release(IAuthorityConnector connector)
+    throws ManifoldCFException
+  {
+    AuthorityConnectorFactory.release(connector);
+  }
+
+  /** Idle notification for inactive authority connector handles.
+  * This method polls all inactive handles.
+  */
+  @Override
+  public void pollAllConnectors()
+    throws ManifoldCFException
+  {
+    AuthorityConnectorFactory.pollAllConnectors(threadContext);
+  }
+
+  /** Clean up all open authority connector handles.
+  * This method is called when the connector pool needs to be flushed,
+  * to free resources.
+  */
+  @Override
+  public void closeAllConnectors()
+    throws ManifoldCFException
+  {
+    AuthorityConnectorFactory.closeAllConnectors(threadContext);
+  }
+
+}

Propchange: 
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authorityconnectorpool/AuthorityConnectorPool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authorityconnectorpool/AuthorityConnectorPool.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: 
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorFactory.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorFactory.java?rev=1547696&r1=1547695&r2=1547696&view=diff
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorFactory.java
 (original)
+++ 
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorFactory.java
 Wed Dec  4 02:56:02 2013
@@ -122,7 +122,17 @@ public class AuthorityConnectorFactory e
     return thisFactory.getThisConnectorNoCheck(className);
   }
 
-  /** Get a repository connector.
+  /** Get multiple authority connectors, all at once.  Do this in a particular 
order
+  * so that any connector exhaustion will not cause a deadlock.
+  */
+  public static IAuthorityConnector[] grabMultiple(IThreadContext 
threadContext,
+    String[] orderingKeys, String[] classNames, ConfigParams[] configInfos, 
int[] maxPoolSizes)
+    throws ManifoldCFException
+  {
+    return 
thisFactory.grabThisMultiple(threadContext,IAuthorityConnector.class,orderingKeys,classNames,configInfos,maxPoolSizes);
+  }
+
+  /** Get an authority connector.
   * The connector is specified by its class and its parameters.
   *@param threadContext is the current thread context.
   *@param className is the name of the class to get a connector for.
@@ -136,7 +146,15 @@ public class AuthorityConnectorFactory e
     return 
thisFactory.grabThis(threadContext,className,configInfo,maxPoolSize);
   }
 
-  /** Release a repository connector.
+  /** Release multiple authority connectors.
+  */
+  public static void releaseMultiple(IAuthorityConnector[] connectors)
+    throws ManifoldCFException
+  {
+    thisFactory.releaseThisMultiple(connectors);
+  }
+
+  /** Release an authority connector.
   *@param connector is the connector to release.
   */
   public static void release(IAuthorityConnector connector)

Added: 
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorPoolFactory.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorPoolFactory.java?rev=1547696&view=auto
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorPoolFactory.java
 (added)
+++ 
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorPoolFactory.java
 Wed Dec  4 02:56:02 2013
@@ -0,0 +1,54 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.manifoldcf.authorities.interfaces;
+
+import org.apache.manifoldcf.core.interfaces.*;
+
+import java.util.*;
+
+/** Authority connector pool manager factory.
+*/
+public class AuthorityConnectorPoolFactory
+{
+  public static final String _rcsid = "@(#)$Id$";
+
+  // name to use in thread context pool of objects
+  private final static String objectName = "_AuthorityConnectorPoolMgr_";
+
+  private AuthorityConnectorPoolFactory()
+  {
+  }
+
+  /** Make an output connector pool handle.
+  *@param tc is the thread context.
+  *@return the handle.
+  */
+  public static IAuthorityConnectorPool make(IThreadContext tc)
+    throws ManifoldCFException
+  {
+    Object o = tc.get(objectName);
+    if (o == null || !(o instanceof IAuthorityConnectorPool))
+    {
+      o = new 
org.apache.manifoldcf.authorities.authorityconnectorpool.AuthorityConnectorPool(tc);
+      tc.save(objectName,o);
+    }
+    return (IAuthorityConnectorPool)o;
+  }
+
+}

Propchange: 
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorPoolFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorPoolFactory.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: 
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnectorPool.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnectorPool.java?rev=1547696&view=auto
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnectorPool.java
 (added)
+++ 
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnectorPool.java
 Wed Dec  4 02:56:02 2013
@@ -0,0 +1,74 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.manifoldcf.authorities.interfaces;
+
+import org.apache.manifoldcf.core.interfaces.*;
+
+import java.util.*;
+import java.io.*;
+
+/** An object implementing this interface functions as a pool of authority 
connectors.
+* Coordination and allocation among cluster members is managed within. 
+* These objects are thread-local, so do not share them among threads.
+*/
+public interface IAuthorityConnectorPool
+{
+  public static final String _rcsid = "@(#)$Id$";
+
+  /** Get multiple authority connectors, all at once.  Do this in a particular 
order
+  * so that any connector exhaustion will not cause a deadlock.
+  *@param orderingKeys are the keys which determine in what order the 
connectors are obtained.
+  *@param authorityConnections are the connections to use the build the 
connector instances.
+  */
+  public IAuthorityConnector[] grabMultiple(String[] orderingKeys, 
IAuthorityConnection[] authorityConnections)
+    throws ManifoldCFException;
+
+  /** Get an authority connector.
+  * The connector is specified by an authority connection object.
+  *@param outputConnection is the authority connection to base the connector 
instance on.
+  */
+  public IAuthorityConnector grab(IAuthorityConnection authorityConnection)
+    throws ManifoldCFException;
+
+  /** Release multiple authority connectors.
+  *@param connectors are the connector instances to release.
+  */
+  public void releaseMultiple(IAuthorityConnector[] connectors)
+    throws ManifoldCFException;
+
+  /** Release an authority connector.
+  *@param connector is the connector to release.
+  */
+  public void release(IAuthorityConnector connector)
+    throws ManifoldCFException;
+
+  /** Idle notification for inactive authority connector handles.
+  * This method polls all inactive handles.
+  */
+  public void pollAllConnectors()
+    throws ManifoldCFException;
+
+  /** Clean up all open authority connector handles.
+  * This method is called when the connector pool needs to be flushed,
+  * to free resources.
+  */
+  public void closeAllConnectors()
+    throws ManifoldCFException;
+
+}

Propchange: 
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnectorPool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnectorPool.java
------------------------------------------------------------------------------
    svn:keywords = Id


Reply via email to