Class AbstractConnPool<T,​C,​E extends PoolEntry<T,​C>>

    • Constructor Detail

      • AbstractConnPool

        public AbstractConnPool​(ConnFactory<T,​C> connFactory,
                                int defaultMaxPerRoute,
                                int maxTotal)
    • Method Detail

      • isShutdown

        public boolean isShutdown()
      • lease

        public Future<E> lease​(T route,
                               Object state,
                               FutureCallback<E> callback)
        Attempts to lease a connection for the given route and with the given state from the pool.

        Please note that this class does not maintain its own pool of execution Threads. Therefore, one must call Future.get() or Future.get(long, TimeUnit) method on the Future returned by this method in order for the lease operation to complete.

        Specified by:
        lease in interface ConnPool<T,​C>
        Parameters:
        route - route of the connection.
        state - arbitrary object that represents a particular state (usually a security principal or a unique token identifying the user whose credentials have been used while establishing the connection). May be null.
        callback - operation completion callback.
        Returns:
        future for a leased pool entry.
      • lease

        public Future<E> lease​(T route,
                               Object state)
        Attempts to lease a connection for the given route and with the given state from the pool.

        Please note that this class does not maintain its own pool of execution Threads. Therefore, one must call Future.get() or Future.get(long, TimeUnit) method on the Future returned by this method in order for the lease operation to complete.

        Parameters:
        route - route of the connection.
        state - arbitrary object that represents a particular state (usually a security principal or a unique token identifying the user whose credentials have been used while establishing the connection). May be null.
        Returns:
        future for a leased pool entry.
      • release

        public void release​(E entry,
                            boolean reusable)
        Description copied from interface: ConnPool
        Releases the pool entry back to the pool.
        Specified by:
        release in interface ConnPool<T,​C>
        Parameters:
        entry - pool entry leased from the pool
        reusable - flag indicating whether or not the released connection is in a consistent state and is safe for further use.
      • getRoutes

        public Set<T> getRoutes()
        Returns snapshot of all knows routes
        Returns:
        the set of routes
        Since:
        4.4
      • closeIdle

        public void closeIdle​(long idletime,
                              TimeUnit tunit)
        Closes connections that have been idle longer than the given period of time and evicts them from the pool.
        Parameters:
        idletime - maximum idle time.
        tunit - time unit.
      • closeExpired

        public void closeExpired()
        Closes expired connections and evicts them from the pool.
      • getValidateAfterInactivity

        public int getValidateAfterInactivity()
        Returns:
        the number of milliseconds
        Since:
        4.4
      • setValidateAfterInactivity

        public void setValidateAfterInactivity​(int ms)
        Parameters:
        ms - the number of milliseconds
        Since:
        4.4