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:07:54 UTC
svn commit: r1547793 - in
/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities:
interfaces/ mappingconnectorpool/
Author: kwright
Date: Wed Dec 4 13:07:54 2013
New Revision: 1547793
URL: http://svn.apache.org/r1547793
Log:
Add a thread-local mapping connector pool object
Added:
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IMappingConnectorPool.java (with props)
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorPoolFactory.java (with props)
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/mappingconnectorpool/
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/mappingconnectorpool/MappingConnectorPool.java (with props)
Modified:
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorFactory.java
Added: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IMappingConnectorPool.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IMappingConnectorPool.java?rev=1547793&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IMappingConnectorPool.java (added)
+++ manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IMappingConnectorPool.java Wed Dec 4 13:07:54 2013
@@ -0,0 +1,79 @@
+/* $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 mapping connectors.
+* Coordination and allocation among cluster members is managed within.
+* These objects are thread-local, so do not share them among threads.
+*/
+public interface IMappingConnectorPool
+{
+ public static final String _rcsid = "@(#)$Id$";
+
+ /** Get multiple mapping 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 mappingConnections are the connections to use the build the connector instances.
+ */
+ public IMappingConnector[] grabMultiple(String[] orderingKeys, IMappingConnection[] mappingConnections)
+ throws ManifoldCFException;
+
+ /** Get a mapping connector.
+ * The connector is specified by a mapping connection object.
+ *@param mappingConnection is the mapping connection to base the connector instance on.
+ */
+ public IMappingConnector grab(IMappingConnection mappingConnection)
+ throws ManifoldCFException;
+
+ /** Release multiple mapping connectors.
+ *@param connectors are the connector instances to release.
+ */
+ public void releaseMultiple(IMappingConnector[] connectors)
+ throws ManifoldCFException;
+
+ /** Release a mapping connector.
+ *@param connector is the connector to release.
+ */
+ public void release(IMappingConnector connector)
+ throws ManifoldCFException;
+
+ /** Idle notification for inactive mapping connector handles.
+ * This method polls all inactive handles.
+ */
+ public void pollAllConnectors()
+ throws ManifoldCFException;
+
+ /** Flush only those connector handles that are currently unused.
+ */
+ public void flushUnusedConnectors()
+ throws ManifoldCFException;
+
+ /** Clean up all open mapping 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/IMappingConnectorPool.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IMappingConnectorPool.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorFactory.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorFactory.java?rev=1547793&r1=1547792&r2=1547793&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorFactory.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorFactory.java Wed Dec 4 13:07:54 2013
@@ -104,6 +104,16 @@ public class MappingConnectorFactory ext
return thisFactory.getThisConnectorNoCheck(className);
}
+ /** Get multiple mapping connectors, all at once. Do this in a particular order
+ * so that any connector exhaustion will not cause a deadlock.
+ */
+ public static IMappingConnector[] grabMultiple(IThreadContext threadContext,
+ String[] orderingKeys, String[] classNames, ConfigParams[] configInfos, int[] maxPoolSizes)
+ throws ManifoldCFException
+ {
+ return thisFactory.grabThisMultiple(threadContext,IMappingConnector.class,orderingKeys,classNames,configInfos,maxPoolSizes);
+ }
+
/** Get a mapping connector.
* The connector is specified by its class and its parameters.
*@param threadContext is the current thread context.
@@ -118,6 +128,14 @@ public class MappingConnectorFactory ext
return thisFactory.grabThis(threadContext,className,configInfo,maxPoolSize);
}
+ /** Release multiple mapping connectors.
+ */
+ public static void releaseMultiple(IMappingConnector[] connectors)
+ throws ManifoldCFException
+ {
+ thisFactory.releaseThisMultiple(connectors);
+ }
+
/** Release a repository connector.
*@param connector is the connector to release.
*/
Added: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorPoolFactory.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorPoolFactory.java?rev=1547793&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorPoolFactory.java (added)
+++ manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorPoolFactory.java Wed Dec 4 13:07:54 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.*;
+
+/** Mapping connector pool manager factory.
+*/
+public class MappingConnectorPoolFactory
+{
+ public static final String _rcsid = "@(#)$Id$";
+
+ // name to use in thread context pool of objects
+ private final static String objectName = "_MappingConnectorPoolMgr_";
+
+ private MappingConnectorPoolFactory()
+ {
+ }
+
+ /** Make a mapping connector pool handle.
+ *@param tc is the thread context.
+ *@return the handle.
+ */
+ public static IMappingConnectorPool make(IThreadContext tc)
+ throws ManifoldCFException
+ {
+ Object o = tc.get(objectName);
+ if (o == null || !(o instanceof IMappingConnectorPool))
+ {
+ o = new org.apache.manifoldcf.authorities.mappingconnectorpool.MappingConnectorPool(tc);
+ tc.save(objectName,o);
+ }
+ return (IMappingConnectorPool)o;
+ }
+
+}
Propchange: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorPoolFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorPoolFactory.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/mappingconnectorpool/MappingConnectorPool.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/mappingconnectorpool/MappingConnectorPool.java?rev=1547793&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/mappingconnectorpool/MappingConnectorPool.java (added)
+++ manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/mappingconnectorpool/MappingConnectorPool.java Wed Dec 4 13:07:54 2013
@@ -0,0 +1,135 @@
+/* $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.mappingconnectorpool;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.authorities.interfaces.*;
+
+import java.util.*;
+import java.io.*;
+
+/** An implementation of IMappingConnectorPool.
+* Coordination and allocation among cluster members is managed within.
+* These objects are thread-local, so do not share them among threads.
+*/
+public class MappingConnectorPool implements IMappingConnectorPool
+{
+ 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 MappingConnectorFactory.
+
+ /** Thread context */
+ protected final IThreadContext threadContext;
+
+ /** Constructor */
+ public MappingConnectorPool(IThreadContext threadContext)
+ throws ManifoldCFException
+ {
+ this.threadContext = threadContext;
+ }
+
+ /** Get multiple mapping 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 mappingConnections are the connections to use the build the connector instances.
+ */
+ @Override
+ public IMappingConnector[] grabMultiple(String[] orderingKeys, IMappingConnection[] mappingConnections)
+ throws ManifoldCFException
+ {
+ // For now, use the MappingConnectorFactory method. This will require us to extract info
+ // from each mapping connection, however.
+ String[] classNames = new String[mappingConnections.length];
+ ConfigParams[] configInfos = new ConfigParams[mappingConnections.length];
+ int[] maxPoolSizes = new int[mappingConnections.length];
+
+ for (int i = 0; i < mappingConnections.length; i++)
+ {
+ classNames[i] = mappingConnections[i].getClassName();
+ configInfos[i] = mappingConnections[i].getConfigParams();
+ maxPoolSizes[i] = mappingConnections[i].getMaxConnections();
+ }
+ return MappingConnectorFactory.grabMultiple(threadContext,
+ orderingKeys, classNames, configInfos, maxPoolSizes);
+ }
+
+ /** Get a mapping connector.
+ * The connector is specified by an mapping connection object.
+ *@param mappingConnection is the mapping connection to base the connector instance on.
+ */
+ @Override
+ public IMappingConnector grab(IMappingConnection mappingConnection)
+ throws ManifoldCFException
+ {
+ return MappingConnectorFactory.grab(threadContext, mappingConnection.getClassName(),
+ mappingConnection.getConfigParams(), mappingConnection.getMaxConnections());
+ }
+
+ /** Release multiple mapping connectors.
+ *@param connectors are the connector instances to release.
+ */
+ @Override
+ public void releaseMultiple(IMappingConnector[] connectors)
+ throws ManifoldCFException
+ {
+ MappingConnectorFactory.releaseMultiple(connectors);
+ }
+
+ /** Release a mapping connector.
+ *@param connector is the connector to release.
+ */
+ @Override
+ public void release(IMappingConnector connector)
+ throws ManifoldCFException
+ {
+ MappingConnectorFactory.release(connector);
+ }
+
+ /** Idle notification for inactive mapping connector handles.
+ * This method polls all inactive handles.
+ */
+ @Override
+ public void pollAllConnectors()
+ throws ManifoldCFException
+ {
+ MappingConnectorFactory.pollAllConnectors(threadContext);
+ }
+
+ /** Flush only those connector handles that are currently unused.
+ */
+ @Override
+ public void flushUnusedConnectors()
+ throws ManifoldCFException
+ {
+ MappingConnectorFactory.flushUnusedConnectors(threadContext);
+ }
+
+ /** Clean up all open mapping connector handles.
+ * This method is called when the connector pool needs to be flushed,
+ * to free resources.
+ */
+ @Override
+ public void closeAllConnectors()
+ throws ManifoldCFException
+ {
+ MappingConnectorFactory.closeAllConnectors(threadContext);
+ }
+
+}
Propchange: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/mappingconnectorpool/MappingConnectorPool.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/mappingconnectorpool/MappingConnectorPool.java
------------------------------------------------------------------------------
svn:keywords = Id