Author: kwright
Date: Thu Dec 5 01:03:06 2013
New Revision: 1547981
URL: http://svn.apache.org/r1547981
Log:
Move the connector pool into RepositoryConnectorPool
Modified:
manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/editjob.jsp
manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/execute.jsp
manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/viewconnection.jsp
manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/viewjob.jsp
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/RepositoryConnectorFactory.java
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/repositoryconnectorpool/RepositoryConnectorPool.java
Modified:
manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/editjob.jsp
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/editjob.jsp?rev=1547981&r1=1547980&r2=1547981&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/editjob.jsp
(original)
+++
manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/editjob.jsp
Thu Dec 5 01:03:06 2013
@@ -37,6 +37,7 @@
IOutputConnection[] outputList = outputMgr.getAllConnections();
IOutputConnectorPool outputConnectorPool =
OutputConnectorPoolFactory.make(threadContext);
+ IRepositoryConnectorPool repositoryConnectorPool =
RepositoryConnectorPoolFactory.make(threadContext);
// Figure out tab name
String tabName = variableContext.getParameter("tabname");
@@ -424,8 +425,7 @@
<%
if (connection != null)
{
- IRepositoryConnector repositoryConnector =
RepositoryConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),
- connection.getMaxConnections());
+ IRepositoryConnector repositoryConnector =
repositoryConnectorPool.grab(connection);
if (repositoryConnector != null)
{
try
@@ -434,7 +434,7 @@
}
finally
{
-
RepositoryConnectorFactory.release(repositoryConnector);
+
repositoryConnectorPool.release(repositoryConnector);
}
}
}
@@ -1292,8 +1292,7 @@
if (connection != null)
{
- IRepositoryConnector repositoryConnector =
RepositoryConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),
- connection.getMaxConnections());
+ IRepositoryConnector repositoryConnector =
repositoryConnectorPool.grab(connection);
if (repositoryConnector != null)
{
try
@@ -1302,7 +1301,7 @@
}
finally
{
-
RepositoryConnectorFactory.release(repositoryConnector);
+
repositoryConnectorPool.release(repositoryConnector);
}
%>
<input type="hidden" name="connectionpresent" value="true"/>
Modified:
manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/execute.jsp
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/execute.jsp?rev=1547981&r1=1547980&r2=1547981&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/execute.jsp
(original)
+++
manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/execute.jsp
Thu Dec 5 01:03:06 2013
@@ -52,6 +52,7 @@
IOutputConnectionManager outputManager =
OutputConnectionManagerFactory.make(threadContext);
IOutputConnectorPool outputConnectorPool =
OutputConnectorPoolFactory.make(threadContext);
+ IRepositoryConnectorPool repositoryConnectorPool =
RepositoryConnectorPoolFactory.make(threadContext);
String type = variableContext.getParameter("type");
String op = variableContext.getParameter("op");
@@ -1054,8 +1055,7 @@
if (connectionPresent && connection !=
null)
{
- IRepositoryConnector
repositoryConnector = RepositoryConnectorFactory.grab(threadContext,
-
connection.getClassName(),connection.getConfigParams(),connection.getMaxConnections());
+ IRepositoryConnector
repositoryConnector = repositoryConnectorPool.grab(connection);
if (repositoryConnector != null)
{
try
@@ -1072,7 +1072,7 @@
}
finally
{
-
RepositoryConnectorFactory.release(repositoryConnector);
+
repositoryConnectorPool.release(repositoryConnector);
}
}
}
Modified:
manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/viewconnection.jsp
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/viewconnection.jsp?rev=1547981&r1=1547980&r2=1547981&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/viewconnection.jsp
(original)
+++
manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/viewconnection.jsp
Thu Dec 5 01:03:06 2013
@@ -78,6 +78,7 @@
IConnectorManager connectorManager =
ConnectorManagerFactory.make(threadContext);
// Get the connection manager handle
IRepositoryConnectionManager connManager =
RepositoryConnectionManagerFactory.make(threadContext);
+ IRepositoryConnectorPool repositoryConnectorPool =
RepositoryConnectorPoolFactory.make(threadContext);
String connectionName = variableContext.getParameter("connname");
IRepositoryConnection connection = connManager.load(connectionName);
if (connection == null)
@@ -108,7 +109,7 @@
String connectionStatus;
try
{
- IRepositoryConnector c =
RepositoryConnectorFactory.grab(threadContext,className,parameters,maxCount);
+ IRepositoryConnector c =
repositoryConnectorPool.grab(connection);
if (c == null)
connectionStatus =
Messages.getString(pageContext.getRequest().getLocale(),"viewconnection.Connectorisnotinstalled");
else
@@ -119,7 +120,7 @@
}
finally
{
- RepositoryConnectorFactory.release(c);
+ repositoryConnectorPool.release(c);
}
}
}
Modified:
manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/viewjob.jsp
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/viewjob.jsp?rev=1547981&r1=1547980&r2=1547981&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/viewjob.jsp
(original)
+++
manifoldcf/branches/CONNECTORS-781/framework/crawler-ui/src/main/webapp/viewjob.jsp
Thu Dec 5 01:03:06 2013
@@ -72,6 +72,7 @@
IRepositoryConnectionManager connManager =
RepositoryConnectionManagerFactory.make(threadContext);
IOutputConnectorPool outputConnectorPool =
OutputConnectorPoolFactory.make(threadContext);
+ IRepositoryConnectorPool repositoryConnectorPool =
RepositoryConnectorPoolFactory.make(threadContext);
String jobID = variableContext.getParameter("jobid");
IJobDescription job = manager.load(new Long(jobID));
@@ -658,9 +659,7 @@
<%
if (connection != null)
{
- IRepositoryConnector repositoryConnector =
RepositoryConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),
-
- connection.getMaxConnections());
+ IRepositoryConnector repositoryConnector =
repositoryConnectorPool.grab(connection);
if (repositoryConnector != null)
{
try
@@ -669,7 +668,7 @@
}
finally
{
-
RepositoryConnectorFactory.release(repositoryConnector);
+
repositoryConnectorPool.release(repositoryConnector);
}
}
}
Modified:
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/RepositoryConnectorFactory.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/RepositoryConnectorFactory.java?rev=1547981&r1=1547980&r2=1547981&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/RepositoryConnectorFactory.java
(original)
+++
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/RepositoryConnectorFactory.java
Thu Dec 5 01:03:06 2013
@@ -181,71 +181,4 @@ public class RepositoryConnectorFactory
return thisFactory.getThisConnectorNoCheck(className);
}
- /** Get multiple repository connectors, all at once. Do this in a
particular order
- * so that any connector exhaustion will not cause a deadlock.
- */
- public static IRepositoryConnector[] grabMultiple(IThreadContext
threadContext,
- String[] orderingKeys, String[] classNames, ConfigParams[] configInfos,
int[] maxPoolSizes)
- throws ManifoldCFException
- {
- return
thisFactory.grabThisMultiple(threadContext,IRepositoryConnector.class,orderingKeys,classNames,configInfos,maxPoolSizes);
- }
-
- /** Get a repository 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.
- *@param configInfo are the name/value pairs constituting configuration info
- * for this class.
- */
- public static IRepositoryConnector grab(IThreadContext threadContext,
- String className, ConfigParams configInfo, int maxPoolSize)
- throws ManifoldCFException
- {
- return
thisFactory.grabThis(threadContext,className,configInfo,maxPoolSize);
- }
-
- /** Release multiple repository connectors.
- */
- public static void releaseMultiple(IRepositoryConnector[] connectors)
- throws ManifoldCFException
- {
- thisFactory.releaseThisMultiple(connectors);
- }
-
- /** Release a repository connector.
- *@param connector is the connector to release.
- */
- public static void release(IRepositoryConnector connector)
- throws ManifoldCFException
- {
- thisFactory.releaseThis(connector);
- }
-
- /** Idle notification for inactive repository connector handles.
- * This method polls all inactive handles.
- */
- public static void pollAllConnectors(IThreadContext threadContext)
- throws ManifoldCFException
- {
- thisFactory.pollThisAllConnectors(threadContext);
- }
-
- public static void flushUnusedConnectors(IThreadContext threadContext)
- throws ManifoldCFException
- {
- thisFactory.flushThisUnusedConnectors(threadContext);
- }
-
- /** Clean up all open repository connector handles.
- * This method is called when the connector pool needs to be flushed,
- * to free resources.
- *@param threadContext is the local thread context.
- */
- public static void closeAllConnectors(IThreadContext threadContext)
- throws ManifoldCFException
- {
- thisFactory.closeThisAllConnectors(threadContext);
- }
-
}
Modified:
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java?rev=1547981&r1=1547980&r2=1547981&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
(original)
+++
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
Thu Dec 5 01:03:06 2013
@@ -42,6 +42,7 @@ public class JobManager implements IJobM
protected final IDBInterface database;
protected final IOutputConnectionManager outputMgr;
protected final IRepositoryConnectionManager connectionMgr;
+ protected final IRepositoryConnectorPool repositoryConnectorPool;
protected final ILockManager lockManager;
protected final IThreadContext threadContext;
protected final JobQueue jobQueue;
@@ -69,6 +70,7 @@ public class JobManager implements IJobM
eventManager = new EventManager(database);
outputMgr = OutputConnectionManagerFactory.make(threadContext);
connectionMgr = RepositoryConnectionManagerFactory.make(threadContext);
+ repositoryConnectorPool =
RepositoryConnectorPoolFactory.make(threadContext);
lockManager = LockManagerFactory.make(threadContext);
}
@@ -2630,17 +2632,11 @@ public class JobManager implements IJobM
// at the connector factory level to make sure these requests are properly
ordered.
String[] orderingKeys = new String[connections.length];
- String[] classNames = new String[connections.length];
- ConfigParams[] configParams = new ConfigParams[connections.length];
- int[] maxConnections = new int[connections.length];
int k = 0;
while (k < connections.length)
{
IRepositoryConnection connection = connections[k];
orderingKeys[k] = connection.getName();
- classNames[k] = connection.getClassName();
- configParams[k] = connection.getConfigParams();
- maxConnections[k] = connection.getMaxConnections();
k++;
}
@@ -2654,7 +2650,7 @@ public class JobManager implements IJobM
try
{
- IRepositoryConnector[] connectors =
RepositoryConnectorFactory.grabMultiple(threadContext,orderingKeys,classNames,configParams,maxConnections);
+ IRepositoryConnector[] connectors =
repositoryConnectorPool.grabMultiple(orderingKeys,connections);
try
{
// Hand the connectors off to the ThrottleLimit instance
@@ -2770,7 +2766,7 @@ public class JobManager implements IJobM
}
finally
{
- RepositoryConnectorFactory.releaseMultiple(connectors);
+ repositoryConnectorPool.releaseMultiple(connectors);
}
}
finally
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=1547981&r1=1547980&r2=1547981&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
Thu Dec 5 01:03:06 2013
@@ -32,6 +32,9 @@ public class RepositoryConnectorPool imp
{
public static final String _rcsid = "@(#)$Id$";
+ /** Local connector pool */
+ protected final static LocalPool localPool = new LocalPool();
+
// This implementation is a place-holder for the real one, which will likely
fold in the pooling code
// as we strip it out of RepositoryConnectorFactory.
@@ -66,7 +69,7 @@ public class RepositoryConnectorPool imp
configInfos[i] = repositoryConnections[i].getConfigParams();
maxPoolSizes[i] = repositoryConnections[i].getMaxConnections();
}
- return RepositoryConnectorFactory.grabMultiple(threadContext,
+ return localPool.grabMultiple(threadContext,
orderingKeys, classNames, configInfos, maxPoolSizes);
}
@@ -78,7 +81,7 @@ public class RepositoryConnectorPool imp
public IRepositoryConnector grab(IRepositoryConnection repositoryConnection)
throws ManifoldCFException
{
- return RepositoryConnectorFactory.grab(threadContext,
repositoryConnection.getClassName(),
+ return localPool.grab(threadContext, repositoryConnection.getClassName(),
repositoryConnection.getConfigParams(),
repositoryConnection.getMaxConnections());
}
@@ -89,7 +92,7 @@ public class RepositoryConnectorPool imp
public void releaseMultiple(IRepositoryConnector[] connectors)
throws ManifoldCFException
{
- RepositoryConnectorFactory.releaseMultiple(connectors);
+ localPool.releaseMultiple(connectors);
}
/** Release a repository connector.
@@ -99,7 +102,7 @@ public class RepositoryConnectorPool imp
public void release(IRepositoryConnector connector)
throws ManifoldCFException
{
- RepositoryConnectorFactory.release(connector);
+ localPool.release(connector);
}
/** Idle notification for inactive repository connector handles.
@@ -109,7 +112,7 @@ public class RepositoryConnectorPool imp
public void pollAllConnectors()
throws ManifoldCFException
{
- RepositoryConnectorFactory.pollAllConnectors(threadContext);
+ localPool.pollAllConnectors(threadContext);
}
/** Flush only those connector handles that are currently unused.
@@ -118,7 +121,7 @@ public class RepositoryConnectorPool imp
public void flushUnusedConnectors()
throws ManifoldCFException
{
- RepositoryConnectorFactory.flushUnusedConnectors(threadContext);
+ localPool.flushUnusedConnectors(threadContext);
}
/** Clean up all open repository connector handles.
@@ -129,7 +132,30 @@ public class RepositoryConnectorPool imp
public void closeAllConnectors()
throws ManifoldCFException
{
- RepositoryConnectorFactory.closeAllConnectors(threadContext);
+ localPool.closeAllConnectors(threadContext);
+ }
+
+ /** Actual static mapping connector pool */
+ protected static class LocalPool extends
org.apache.manifoldcf.core.connectorpool.ConnectorPool<IRepositoryConnector>
+ {
+ public LocalPool()
+ {
+ }
+
+ @Override
+ protected boolean isInstalled(IThreadContext tc, String className)
+ throws ManifoldCFException
+ {
+ IConnectorManager connectorManager = ConnectorManagerFactory.make(tc);
+ return connectorManager.isInstalled(className);
+ }
+
+ public IRepositoryConnector[] grabMultiple(IThreadContext tc, String[]
orderingKeys, String[] classNames, ConfigParams[] configInfos, int[]
maxPoolSizes)
+ throws ManifoldCFException
+ {
+ return
grabMultiple(tc,IRepositoryConnector.class,orderingKeys,classNames,configInfos,maxPoolSizes);
+ }
+
}
}