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/06 14:43:58 UTC
svn commit: r1548512 - in /manifoldcf/branches/CONNECTORS-781/framework:
agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/
core/src/main/java/org/apache/manifoldcf/core/connectorpool/
pull-agent/src/main/java/org/apache/manifoldcf/...
Author: kwright
Date: Fri Dec 6 13:43:57 2013
New Revision: 1548512
URL: http://svn.apache.org/r1548512
Log:
Register each connector pool + connection name as a service, so we can track it and the number of handles it has outstanding
Modified:
manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/OutputConnectorPool.java
manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/connectorpool/ConnectorPool.java
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authorityconnectorpool/AuthorityConnectorPool.java
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/mappingconnectorpool/MappingConnectorPool.java
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/repositoryconnectorpool/RepositoryConnectorPool.java
Modified: manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/OutputConnectorPool.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/OutputConnectorPool.java?rev=1548512&r1=1548511&r2=1548512&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/OutputConnectorPool.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/OutputConnectorPool.java Fri Dec 6 13:43:57 2013
@@ -162,6 +162,7 @@ public class OutputConnectorPool impleme
{
public LocalPool()
{
+ super("_OUTPUTCONNECTORPOOL_");
}
@Override
Modified: manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/connectorpool/ConnectorPool.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/connectorpool/ConnectorPool.java?rev=1548512&r1=1548511&r2=1548512&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/connectorpool/ConnectorPool.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/connectorpool/ConnectorPool.java Fri Dec 6 13:43:57 2013
@@ -31,12 +31,15 @@ public abstract class ConnectorPool<T ex
{
public static final String _rcsid = "@(#)$Id$";
- // Pool hash table.
- // Keyed by connection name; value is Pool
+ /** Service type prefix */
+ protected final String serviceTypePrefix;
+
+ /** Pool hash table. Keyed by connection name; value is Pool */
protected final Map<String,Pool> poolHash = new HashMap<String,Pool>();
- protected ConnectorPool()
+ protected ConnectorPool(String serviceTypePrefix)
{
+ this.serviceTypePrefix = serviceTypePrefix;
}
// Protected methods
@@ -211,7 +214,7 @@ public abstract class ConnectorPool<T ex
p = poolHash.get(connectionName);
if (p == null)
{
- p = new Pool(maxPoolSize);
+ p = new Pool(threadContext, maxPoolSize, connectionName);
poolHash.put(connectionName,p);
}
}
@@ -300,7 +303,16 @@ public abstract class ConnectorPool<T ex
public void flushUnusedConnectors(IThreadContext threadContext)
throws ManifoldCFException
{
- closeAllConnectors(threadContext);
+ // Go through the whole pool and clean it out
+ synchronized (poolHash)
+ {
+ Iterator<Pool> iter = poolHash.values().iterator();
+ while (iter.hasNext())
+ {
+ Pool p = iter.next();
+ p.flushUnused(threadContext);
+ }
+ }
}
/** Clean up all open output connector handles.
@@ -323,18 +335,32 @@ public abstract class ConnectorPool<T ex
}
}
+ // Protected methods and classes
+
+ protected String buildServiceTypeName(String connectionName)
+ {
+ return serviceTypePrefix + connectionName;
+ }
+
/** This class represents a value in the pool hash, which corresponds to a given key.
*/
- public class Pool
+ protected class Pool
{
+ protected final String serviceTypeName;
+ protected final String serviceName;
protected final List<T> stack = new ArrayList<T>();
protected int numFree;
/** Constructor
*/
- public Pool(int maxCount)
+ public Pool(IThreadContext threadContext, int maxCount, String connectionName)
+ throws ManifoldCFException
{
- numFree = maxCount;
+ this.numFree = maxCount;
+ this.serviceTypeName = buildServiceTypeName(connectionName);
+ // Now, register and activate service anonymously, and record the service name we get.
+ ILockManager lockManager = LockManagerFactory.make(threadContext);
+ this.serviceName = lockManager.registerServiceBeginServiceActivity(serviceTypeName, null, null);
}
/** Grab a connector.
@@ -435,9 +461,9 @@ public abstract class ConnectorPool<T ex
}
}
- /** Release all free connectors.
+ /** Flush unused connectors.
*/
- public synchronized void releaseAll(IThreadContext threadContext)
+ public synchronized void flushUnused(IThreadContext threadContext)
throws ManifoldCFException
{
while (stack.size() > 0)
@@ -456,6 +482,17 @@ public abstract class ConnectorPool<T ex
}
}
+ /** Release all free connectors.
+ */
+ public synchronized void releaseAll(IThreadContext threadContext)
+ throws ManifoldCFException
+ {
+ flushUnused(threadContext);
+ // End service activity
+ ILockManager lockManager = LockManagerFactory.make(threadContext);
+ lockManager.endServiceActivity(serviceTypeName, serviceName);
+ }
+
}
}
Modified: 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=1548512&r1=1548511&r2=1548512&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authorityconnectorpool/AuthorityConnectorPool.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authorityconnectorpool/AuthorityConnectorPool.java Fri Dec 6 13:43:57 2013
@@ -149,6 +149,7 @@ public class AuthorityConnectorPool impl
{
public LocalPool()
{
+ super("_AUTHORITYCONNECTORPOOL_");
}
@Override
Modified: 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=1548512&r1=1548511&r2=1548512&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/mappingconnectorpool/MappingConnectorPool.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/mappingconnectorpool/MappingConnectorPool.java Fri Dec 6 13:43:57 2013
@@ -150,6 +150,7 @@ public class MappingConnectorPool implem
{
public LocalPool()
{
+ super("_MAPPINGCONNECTORPOOL_");
}
@Override
Modified: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/repositoryconnectorpool/RepositoryConnectorPool.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/repositoryconnectorpool/RepositoryConnectorPool.java?rev=1548512&r1=1548511&r2=1548512&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/repositoryconnectorpool/RepositoryConnectorPool.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/repositoryconnectorpool/RepositoryConnectorPool.java Fri Dec 6 13:43:57 2013
@@ -149,6 +149,7 @@ public class RepositoryConnectorPool imp
{
public LocalPool()
{
+ super("_REPOSITORYCONNECTORPOOL_");
}
@Override