Class ConnectionPool.Initializer

java.lang.Object
org.attribyte.sql.pool.ConnectionPool.Initializer
Enclosing class:
ConnectionPool

public static class ConnectionPool.Initializer extends Object
Initializes and creates connection pools.
  • Constructor Details

    • Initializer

      public Initializer()
  • Method Details

    • fromConfig

      public static final List<ConnectionPool.Initializer> fromConfig(com.typesafe.config.Config config, PasswordSource passwordSource, org.attribyte.api.Logger logger) throws org.attribyte.api.InitializationException
      Create an Initializer for each configured pool.
      Parameters:
      config - The configuration.
      passwordSource - The password source. May be null.
      logger - The logger. May be null.
      Returns:
      The list of Initializers.
      Throws:
      org.attribyte.api.InitializationException - on invalid configuration.
    • fromConfigFile

      public static final List<ConnectionPool.Initializer> fromConfigFile(File configFile, PasswordSource passwordSource, org.attribyte.api.Logger logger) throws org.attribyte.api.InitializationException
      Parse a config file to create an Initializer for each configured pool.

      File format is HOCON. Configuration must appear in the path: acp

      Parameters:
      configFile - The config file.
      passwordSource - The password source. May be null.
      logger - The logger. May be null.
      Returns:
      The list of Initializers.
      Throws:
      org.attribyte.api.InitializationException - on invalid file or configuration.
    • fromProperties

      public static final List<ConnectionPool.Initializer> fromProperties(Properties props, PasswordSource passwordSource, org.attribyte.api.Logger logger) throws org.attribyte.api.InitializationException
      Parse properties to create an Initializer for each configured pool.
      Parameters:
      props - The properties.
      passwordSource - The password source. May be null.
      logger - The logger. May be null.
      Returns:
      The list of Initializers.
      Throws:
      org.attribyte.api.InitializationException - on invalid configuration.
    • fromPropertiesFile

      public static final List<ConnectionPool.Initializer> fromPropertiesFile(File propsFile, PasswordSource passwordSource, org.attribyte.api.Logger logger) throws org.attribyte.api.InitializationException
      Parse properties to create an Initializer for each configured pool.
      Parameters:
      propsFile - A properties file.
      passwordSource - The password source. May be null.
      logger - The logger. May be null.
      Returns:
      The list of Initializers.
      Throws:
      org.attribyte.api.InitializationException - on invalid file or configuration.
    • setName

      public ConnectionPool.Initializer setName(String name)
      Sets the name of the pool.
      Parameters:
      name - The name.
      Returns:
      A self-reference.
    • addActiveSegment

      public ConnectionPool.Initializer addActiveSegment(ConnectionPoolSegment segment)
      Adds an active segment to the pool.
      Parameters:
      segment - The segment to add.
      Returns:
      A self-reference.
    • addActiveSegments

      public ConnectionPool.Initializer addActiveSegments(List<ConnectionPoolSegment> segments)
      Adds active segments to the pool.
      Parameters:
      segments - The segments to add.
      Returns:
      A self-reference.
    • addReserveSegment

      public ConnectionPool.Initializer addReserveSegment(ConnectionPoolSegment segment)
      Adds a reserve segment to the pool.
      Parameters:
      segment - The segment to add.
      Returns:
      A self-reference.
    • addReserveSegments

      public ConnectionPool.Initializer addReserveSegments(List<ConnectionPoolSegment> segments)
      Adds reserve segments to the pool.
      Parameters:
      segments - The segments to add.
      Returns:
      A self-reference.
    • setMinActiveSegments

      public ConnectionPool.Initializer setMinActiveSegments(int minActiveSegments)
      Sets the minimum number of active statements.
      Parameters:
      minActiveSegments - The minimum number of active segments.
      Returns:
      A self-reference.
    • setMinSegmentExpansionDelay

      public ConnectionPool.Initializer setMinSegmentExpansionDelay(long minSegmentExpansionDelayMillis)
      Sets the minimum delay between segment expansions in milliseconds.
      Parameters:
      minSegmentExpansionDelayMillis - The delay.
      Returns:
      A self-reference.
    • setIdleCheckInterval

      public ConnectionPool.Initializer setIdleCheckInterval(long idleCheckInterval, TimeUnit idleCheckIntervalUnit)
      Sets the interval between checks for idle segments.
      Parameters:
      idleCheckInterval - The idle check interval.
      idleCheckIntervalUnit - The idle check interval units.
      Returns:
      A self-reference.
    • setSaturatedAcquireTimeout

      public ConnectionPool.Initializer setSaturatedAcquireTimeout(long saturatedAcquireTimeout, TimeUnit saturatedAcquireTimeoutUnit)
      Sets the maximum amount of time to wait for an available connection when pool is saturated.
      Parameters:
      saturatedAcquireTimeout - The saturated acquire timeout.
      saturatedAcquireTimeoutUnit - The saturated acquire timeout units.
      Returns:
      A self-reference.
    • setLogger

      public ConnectionPool.Initializer setLogger(org.attribyte.api.Logger logger)
      Sets the logger.
      Parameters:
      logger - The logger.
      Returns:
      A self-reference.
    • addAlias

      public ConnectionPool.Initializer addAlias(String alias)
      Adds an alias for this pool.
      Parameters:
      alias - The alias name.
      Returns:
      A self-reference.
    • createPool

      public ConnectionPool createPool() throws org.attribyte.api.InitializationException
      Creates a configured pool.
      Returns:
      The pool.
      Throws:
      org.attribyte.api.InitializationException - if pool was improperly configured.
    • getName

      public String getName()
      Returns:
      The name.
    • getAka

      public Set<String> getAka()
      Returns:
      The set of alias names.
    • getMinActiveSegments

      public int getMinActiveSegments()
      Returns:
      The minimum number of active segments.
    • getMinSegmentExpansionDelayMillis

      public long getMinSegmentExpansionDelayMillis()
      Returns:
      The minimum expansion delay in milliseconds.
    • getSaturatedAcquireTimeoutMillis

      public long getSaturatedAcquireTimeoutMillis()
      Returns:
      The saturated acquire timeout in milliseconds.
    • getIdleCheckIntervalMillis

      public long getIdleCheckIntervalMillis()
      Returns:
      The idle check interval in milliseconds.