Interface ConnectionPoolWrapper

All Known Implementing Classes:
AbstractConnectionPoolWrapper

public interface ConnectionPoolWrapper
A connection pool wrapper, providing statistics from the underlying pool and allowing some configuration.
  • Field Details

    • DEFAULT_MAXIMUM_POOL_SIZE

      static final PropertyValue<Integer> DEFAULT_MAXIMUM_POOL_SIZE
      Specifies the default maximum connection pool size. Value type: Integer
      Default value: 8
    • DEFAULT_MINIMUM_POOL_SIZE

      static final PropertyValue<Integer> DEFAULT_MINIMUM_POOL_SIZE
      Specifies the default minimum connection pool size. Value type: Integer
      Default value: 4
    • DEFAULT_IDLE_TIMEOUT

      static final PropertyValue<Integer> DEFAULT_IDLE_TIMEOUT
      Specifies the default idle timeout in milliseconds. Value type: Integer
      Default value: 60.000
  • Method Details

    • connection

      Connection connection(User user) throws DatabaseException
      Fetches a connection from the pool. Close the connection to return it to the pool.
      Parameters:
      user - the user credentials
      Returns:
      a database connection retrieved from the pool
      Throws:
      DatabaseException - in case of an exception while fetching the connection
      IllegalStateException - if the pool is closed
      See Also:
    • user

      User user()
      Returns:
      the user this connection pool is based on.
    • poolDataSource

      DataSource poolDataSource()
      Returns:
      the DataSource used by this connection pool
    • close

      void close()
      Closes this connection pool, connections subsequently checked in are disconnected
    • statistics

      ConnectionPoolStatistics statistics(long since)
      Retrives usage statistics for the connection pool since time since.
      Parameters:
      since - the time from which statistics should be retrieved
      Returns:
      connection pool usage statistics
    • resetStatistics

      void resetStatistics()
      Resets the collected usage statistics
    • isCollectSnapshotStatistics

      boolean isCollectSnapshotStatistics()
      Returns:
      true if pool usage statistics for a snapshot should be collected.
      See Also:
    • setCollectSnapshotStatistics

      void setCollectSnapshotStatistics(boolean collectSnapshotStatistics)
      Specifies whether to collect usage statistics for a snapshot.
      Parameters:
      collectSnapshotStatistics - the value
      See Also:
    • isCollectCheckOutTimes

      boolean isCollectCheckOutTimes()
      Returns:
      true if connection check out times should be collected.
      See Also:
    • setCollectCheckOutTimes

      void setCollectCheckOutTimes(boolean collectCheckOutTimes)
      Specifies whether to collect connection check out times.
      Parameters:
      collectCheckOutTimes - the value
      See Also:
    • getCleanupInterval

      int getCleanupInterval()
      Returns:
      the pool cleanup interval in milliseconds
    • setCleanupInterval

      void setCleanupInterval(int poolCleanupInterval)
      Parameters:
      poolCleanupInterval - the pool cleanup interval in milliseconds
    • getIdleConnectionTimeout

      int getIdleConnectionTimeout()
      Returns:
      the pooled connection timeout in milliseconds, that is, the time that needs to pass before an idle connection can be harvested
    • setIdleConnectionTimeout

      void setIdleConnectionTimeout(int idleConnectionTimeout)
      Parameters:
      idleConnectionTimeout - the pooled connection timeout in milliseconds, that is, the time that needs to pass before an idle connection can be harvested
    • getMinimumPoolSize

      int getMinimumPoolSize()
      Returns:
      the minimum number of connections to keep in the pool
    • setMinimumPoolSize

      void setMinimumPoolSize(int minimumPoolSize)
      Parameters:
      minimumPoolSize - the minimum number of connections to keep in the pool
      Throws:
      IllegalArgumentException - if the value is less than 0 or larger than maximum pool size
    • getMaximumPoolSize

      int getMaximumPoolSize()
      Returns:
      the maximum number of connections this pool can create
    • setMaximumPoolSize

      void setMaximumPoolSize(int maximumPoolSize)
      Sets the maximum number of connections to keep in this pool. Note that if the current number of connections exceeds this value when set, excess connections are not actively discarded.
      Parameters:
      maximumPoolSize - the maximum number of connections this pool can create
      Throws:
      IllegalArgumentException - if the value is less than 1 or less than minimum pool size
    • getMaximumCheckOutTime

      int getMaximumCheckOutTime()
      Returns:
      the maximum number of milliseconds to retry connection checkout before throwing an exception
    • setMaximumCheckOutTime

      void setMaximumCheckOutTime(int maximumCheckOutTime)
      Parameters:
      maximumCheckOutTime - the maximum number of milliseconds to retry connection checkout before throwing an exception, note that this also modifies the new connection threshold, keeping its value to 1/4 of this one
      Throws:
      IllegalArgumentException - if the value is less than 0