Class ConnectorPool<T extends IConnector>
- java.lang.Object
-
- org.apache.manifoldcf.core.connectorpool.ConnectorPool<T>
-
- Direct Known Subclasses:
AuthorityConnectorPool.LocalPool,MappingConnectorPool.LocalPool,NotificationConnectorPool.LocalPool,OutputConnectorPool.LocalPool,RepositoryConnectorPool.LocalPool,TransformationConnectorPool.LocalPool
public abstract class ConnectorPool<T extends IConnector> extends java.lang.ObjectThis is the base factory class for all ConnectorPool objects.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classConnectorPool.PoolThis class represents a value in the pool hash, which corresponds to a given key.protected static classConnectorPool.SumClass
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String_rcsidprotected java.util.Map<java.lang.String,ConnectorPool.Pool>poolHashPool hash table.protected static java.util.RandomrandomNumberGeneratorRandom numberprotected java.lang.StringserviceTypePrefixService type prefixprotected static java.lang.StringtargetCalcLockPrefixTarget calc lock prefix
-
Constructor Summary
Constructors Modifier Constructor Description protectedConnectorPool(java.lang.String serviceTypePrefix)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringbuildServiceTypeName(java.lang.String connectionName)protected java.lang.StringbuildTargetCalcLockName(java.lang.String connectionName)voidcloseAllConnectors(IThreadContext threadContext)Clean up all open output connector handles.protected TcreateConnectorInstance(IThreadContext threadContext, java.lang.String className)Get a connector instance.voidflushUnusedConnectors(IThreadContext threadContext)Flush only those connector handles that are currently unused.Tgrab(IThreadContext threadContext, java.lang.String connectionName, java.lang.String className, ConfigParams configInfo, int maxPoolSize)Get a connector.T[]grabMultiple(IThreadContext threadContext, java.lang.Class<T> clazz, java.lang.String[] orderingKeys, java.lang.String[] connectionNames, java.lang.String[] classNames, ConfigParams[] configInfos, int[] maxPoolSizes)Get multiple connectors, all at once.protected abstract booleanisConnectionNameValid(IThreadContext tc, java.lang.String connectionName)Override this method to check if a connection name is still valid.protected abstract booleanisInstalled(IThreadContext tc, java.lang.String className)Override this method to hook into a connector manager.protected static byte[]pack(int target, int inUse)voidpollAllConnectors(IThreadContext threadContext)Idle notification for inactive output connector handles.voidrelease(IThreadContext threadContext, java.lang.String connectionName, T connector)Release an output connector.voidreleaseMultiple(IThreadContext threadContext, java.lang.String[] connectionNames, T[] connectors)Release multiple output connectors.protected static intunpackInUse(byte[] data)protected static intunpackTarget(byte[] data)
-
-
-
Field Detail
-
_rcsid
public static final java.lang.String _rcsid
- See Also:
- Constant Field Values
-
targetCalcLockPrefix
protected static final java.lang.String targetCalcLockPrefix
Target calc lock prefix- See Also:
- Constant Field Values
-
serviceTypePrefix
protected final java.lang.String serviceTypePrefix
Service type prefix
-
poolHash
protected final java.util.Map<java.lang.String,ConnectorPool.Pool> poolHash
Pool hash table. Keyed by connection name; value is Pool
-
randomNumberGenerator
protected static final java.util.Random randomNumberGenerator
Random number
-
-
Method Detail
-
isInstalled
protected abstract boolean isInstalled(IThreadContext tc, java.lang.String className) throws ManifoldCFException
Override this method to hook into a connector manager.- Throws:
ManifoldCFException
-
isConnectionNameValid
protected abstract boolean isConnectionNameValid(IThreadContext tc, java.lang.String connectionName) throws ManifoldCFException
Override this method to check if a connection name is still valid.- Throws:
ManifoldCFException
-
createConnectorInstance
protected T createConnectorInstance(IThreadContext threadContext, java.lang.String className) throws ManifoldCFException
Get a connector instance.- Parameters:
className- is the class name.- Returns:
- the instance.
- Throws:
ManifoldCFException
-
grabMultiple
public T[] grabMultiple(IThreadContext threadContext, java.lang.Class<T> clazz, java.lang.String[] orderingKeys, java.lang.String[] connectionNames, java.lang.String[] classNames, ConfigParams[] configInfos, int[] maxPoolSizes) throws ManifoldCFException
Get multiple connectors, all at once. Do this in a particular order so that any connector exhaustion will not cause a deadlock.- Throws:
ManifoldCFException
-
grab
public T grab(IThreadContext threadContext, java.lang.String connectionName, java.lang.String className, ConfigParams configInfo, int maxPoolSize) throws ManifoldCFException
Get a connector. The connector is specified by its connection name, class, and parameters. If the class and parameters corresponding to a connection name change, then this code will destroy any old connector instance that does not correspond, and create a new one using the new class and parameters.- Parameters:
threadContext- is the current thread context.connectionName- is the name of the connection. This functions as a pool key.className- is the name of the class to get a connector for.configInfo- are the name/value pairs constituting configuration info for this class.- Throws:
ManifoldCFException
-
releaseMultiple
public void releaseMultiple(IThreadContext threadContext, java.lang.String[] connectionNames, T[] connectors) throws ManifoldCFException
Release multiple output connectors.- Throws:
ManifoldCFException
-
release
public void release(IThreadContext threadContext, java.lang.String connectionName, T connector) throws ManifoldCFException
Release an output connector.- Parameters:
connectionName- is the connection name.connector- is the connector to release.- Throws:
ManifoldCFException
-
pollAllConnectors
public void pollAllConnectors(IThreadContext threadContext) throws ManifoldCFException
Idle notification for inactive output connector handles. This method polls all inactive handles.- Throws:
ManifoldCFException
-
flushUnusedConnectors
public void flushUnusedConnectors(IThreadContext threadContext) throws ManifoldCFException
Flush only those connector handles that are currently unused.- Throws:
ManifoldCFException
-
closeAllConnectors
public void closeAllConnectors(IThreadContext threadContext) throws ManifoldCFException
Clean up all open output connector handles. This method is called when the connector pool needs to be flushed, to free resources.- Parameters:
threadContext- is the local thread context.- Throws:
ManifoldCFException
-
buildServiceTypeName
protected java.lang.String buildServiceTypeName(java.lang.String connectionName)
-
buildTargetCalcLockName
protected java.lang.String buildTargetCalcLockName(java.lang.String connectionName)
-
unpackTarget
protected static int unpackTarget(byte[] data)
-
unpackInUse
protected static int unpackInUse(byte[] data)
-
pack
protected static byte[] pack(int target, int inUse)
-
-