Class ConnectorPool<T extends IConnector>

    • Field Detail

      • 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
    • Constructor Detail

      • ConnectorPool

        protected ConnectorPool​(java.lang.String serviceTypePrefix)
    • Method Detail

      • 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
      • 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
      • 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)