Interface ConnectionPool<E extends AutoCloseable>

Type Parameters:
E - the type of the connections in the pool.
All Superinterfaces:
AutoCloseable, Iterable<E>
All Known Implementing Classes:
AbstractClientConnectionPool, AbstractConnectionPool, JPPFConnectionPool

public interface ConnectionPool<E extends AutoCloseable> extends Iterable<E>, AutoCloseable
Interface for pools of connections with a maximum size which can be dynamically updated.
Since:
4.2
Author:
Laurent Cohen
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(E connection)
    Add a connection to this pool.
    int
    Get the current size of this pool.
    Get the next connection that is connected and available.
    Get a list of connections held by this pool.
    int
    Get the maximum size of this connection pool.
    boolean
    Determine whether this pool is empty.
    Get the next connection.
    boolean
    remove(E connection)
    Remove a connection from this pool.
    int
    setSize(int maxSize)
    Set the size of this connection pool, starting or stopping connections as needed.

    Methods inherited from interface java.lang.AutoCloseable

    close

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Method Details

    • add

      boolean add(E connection)
      Add a connection to this pool.
      Parameters:
      connection - the connection too add.
      Returns:
      true if the underlying list of connections changed as a result of calling this method.
    • remove

      boolean remove(E connection)
      Remove a connection from this pool.
      Parameters:
      connection - the connection too remove.
      Returns:
      true if the underlying list of connections changed as a result of calling this method.
    • nextConnection

      E nextConnection()
      Get the next connection.
      Returns:
      a connection.
    • getConnection

      E getConnection()
      Get the next connection that is connected and available.
      Returns:
      a connection object if one is found in the desired state, or null otherwise.
    • isEmpty

      boolean isEmpty()
      Determine whether this pool is empty.
      Returns:
      true if this pool is empty, false otherwise.
    • connectionCount

      int connectionCount()
      Get the current size of this pool.
      Returns:
      the size as an int.
    • getSize

      int getSize()
      Get the maximum size of this connection pool.
      Returns:
      the max size as an int.
    • setSize

      int setSize(int maxSize)
      Set the size of this connection pool, starting or stopping connections as needed.

      If any connection to be stopped is currently executing a job, then it will not be stopped.

      Parameters:
      maxSize - the max size as an int.
      Returns:
      the new maximum pool size.
    • getConnections

      List<E> getConnections()
      Get a list of connections held by this pool. The returned list is independent from this pool, thus changing, adding or removing elements has not effect on the pool.
      Returns:
      a list of JPPFClientConnection instances.