Class PoolOptions

java.lang.Object
io.vertx.sqlclient.PoolOptions

public class PoolOptions extends Object
The options for configuring a connection pool.
Author:
Julien Viet
  • Field Details

    • DEFAULT_MAX_SIZE

      public static final int DEFAULT_MAX_SIZE
      The default maximum number of connections a client will pool = 4
      See Also:
    • DEFAULT_MAX_WAIT_QUEUE_SIZE

      public static final int DEFAULT_MAX_WAIT_QUEUE_SIZE
      Default max wait queue size = -1 (unbounded)
      See Also:
    • DEFAULT_IDLE_TIMEOUT

      public static final int DEFAULT_IDLE_TIMEOUT
      Default connection timeout in the pool = 0 (no timeout)
      See Also:
    • DEFAULT_MAXIMUM_LIFETIME

      public static final int DEFAULT_MAXIMUM_LIFETIME
      Default maximum pooled connection lifetime = 0 (no maximum)
      See Also:
    • DEFAULT_IDLE_TIMEOUT_TIME_UNIT

      public static final TimeUnit DEFAULT_IDLE_TIMEOUT_TIME_UNIT
      Default connection idle time unit in the pool = seconds
    • DEFAULT_MAXIMUM_LIFETIME_TIME_UNIT

      public static final TimeUnit DEFAULT_MAXIMUM_LIFETIME_TIME_UNIT
      Default maximum pooled connection lifetime unit = seconds
    • DEFAULT_POOL_CLEANER_PERIOD

      public static final int DEFAULT_POOL_CLEANER_PERIOD
      Default pool cleaner period = 1000 ms (1 second)
      See Also:
    • DEFAULT_CONNECTION_TIMEOUT

      public static final int DEFAULT_CONNECTION_TIMEOUT
      Default connection timeout in the pool = 30 seconds
      See Also:
    • DEFAULT_CONNECTION_TIMEOUT_TIME_UNIT

      public static final TimeUnit DEFAULT_CONNECTION_TIMEOUT_TIME_UNIT
      Default connection idle time unit in the pool = seconds
    • DEFAULT_SHARED_POOL

      public static final boolean DEFAULT_SHARED_POOL
      Default shared pool config = false
      See Also:
    • DEFAULT_NAME

      public static final String DEFAULT_NAME
      Actual name of anonymous shared pool = __vertx.DEFAULT
      See Also:
    • DEFAULT_EVENT_LOOP_SIZE

      public static final int DEFAULT_EVENT_LOOP_SIZE
      Default pool event loop size = 0 (reuse current event-loop)
      See Also:
  • Constructor Details

    • PoolOptions

      public PoolOptions()
    • PoolOptions

      public PoolOptions(JsonObject json)
    • PoolOptions

      public PoolOptions(PoolOptions other)
  • Method Details

    • getMaxSize

      public int getMaxSize()
      Returns:
      the maximum pool size
    • setMaxSize

      public PoolOptions setMaxSize(int maxSize)
      Set the maximum pool size
      Parameters:
      maxSize - the maximum pool size
      Returns:
      a reference to this, so the API can be used fluently
    • getMaxWaitQueueSize

      public int getMaxWaitQueueSize()
      Returns:
      the maximum wait queue size
    • setMaxWaitQueueSize

      public PoolOptions setMaxWaitQueueSize(int maxWaitQueueSize)
      Set the maximum connection request allowed in the wait queue, any requests beyond the max size will result in an failure. If the value is set to a negative number then the queue will be unbounded.
      Parameters:
      maxWaitQueueSize - the maximum number of waiting requests
      Returns:
      a reference to this, so the API can be used fluently
    • getIdleTimeoutUnit

      public TimeUnit getIdleTimeoutUnit()
      Returns:
      the pooled connection idle timeout unit
    • setIdleTimeoutUnit

      public PoolOptions setIdleTimeoutUnit(TimeUnit idleTimeoutUnit)
      Establish an idle timeout unit for pooled connections.
      Parameters:
      idleTimeoutUnit - pooled connection idle time unit
      Returns:
      a reference to this, so the API can be used fluently
    • getIdleTimeout

      public int getIdleTimeout()
      Returns:
      pooled connection idle timeout
    • setIdleTimeout

      public PoolOptions setIdleTimeout(int idleTimeout)
      Establish an idle timeout for pooled connections, a value of zero disables the idle timeout.
      Parameters:
      idleTimeout - the pool connection idle timeout
      Returns:
      a reference to this, so the API can be used fluently
    • getMaxLifetimeUnit

      public TimeUnit getMaxLifetimeUnit()
      Returns:
      the pooled connection max lifetime unit
    • setMaxLifetimeUnit

      public PoolOptions setMaxLifetimeUnit(TimeUnit maxLifetimeUnit)
      Establish a max lifetime unit for pooled connections.
      Parameters:
      maxLifetimeUnit - pooled connection max lifetime unit
      Returns:
      a reference to this, so the API can be used fluently
    • getMaxLifetime

      public int getMaxLifetime()
      Returns:
      pooled connection max lifetime
    • setMaxLifetime

      public PoolOptions setMaxLifetime(int maxLifetime)
      Establish a max lifetime for pooled connections, a value of zero disables the maximum lifetime.
      Parameters:
      maxLifetime - the pool connection max lifetime
      Returns:
      a reference to this, so the API can be used fluently
    • getPoolCleanerPeriod

      public int getPoolCleanerPeriod()
      Returns:
      the connection pool cleaner period in ms.
    • setPoolCleanerPeriod

      public PoolOptions setPoolCleanerPeriod(int poolCleanerPeriod)
      Set the connection pool cleaner period in milli seconds, a non positive value disables expiration checks and connections will remain in the pool until they are closed.
      Parameters:
      poolCleanerPeriod - the pool cleaner period
      Returns:
      a reference to this, so the API can be used fluently
    • getConnectionTimeoutUnit

      public TimeUnit getConnectionTimeoutUnit()
      Returns:
      the time unit of @link #setConnectionTimeout(int)}
    • setConnectionTimeoutUnit

      public PoolOptions setConnectionTimeoutUnit(TimeUnit timeoutUnit)
      Set the time unit of setConnectionTimeout(int)
      Parameters:
      timeoutUnit - the time unit
      Returns:
      a reference to this, so the API can be used fluently
    • getConnectionTimeout

      public int getConnectionTimeout()
      Returns:
      the amount of time a client will wait for a connection from the pool. See setConnectionTimeout(int)
    • setConnectionTimeout

      public PoolOptions setConnectionTimeout(int timeout)
      Set the amount of time a client will wait for a connection from the pool. If the time is exceeded without a connection available, an exception is provided.
      Parameters:
      timeout - the pool connection idle time unit
      Returns:
      a reference to this, so the API can be used fluently
    • isShared

      public boolean isShared()
      Returns:
      whether the pool is shared
    • setShared

      public PoolOptions setShared(boolean shared)
      Set to true to share the pool.

      There can be multiple shared pools distinguished by getName(), when no specific name is set, the DEFAULT_NAME is used.

      Parameters:
      shared - true to use a shared pool
      Returns:
      a reference to this, so the API can be used fluently
    • getName

      public String getName()
      Returns:
      the pool name
    • setName

      public PoolOptions setName(String name)
      Set the pool name, used when the pool shared, otherwise ignored.
      Parameters:
      name - the new name
      Returns:
      a reference to this, so the API can be used fluently
    • getEventLoopSize

      public int getEventLoopSize()
      Returns:
      the max number of event-loop a pool will use, the default value is 0 which implies to reuse the current event-loop
    • setEventLoopSize

      public PoolOptions setEventLoopSize(int eventLoopSize)
      Set the number of event-loop the pool use.
      • when the size is 0, the client pool will use the current event-loop
      • otherwise the client will create and use its own event loop
      The default size is 0.
      Parameters:
      eventLoopSize - the new size
      Returns:
      a reference to this, so the API can be used fluently
    • toJson

      public JsonObject toJson()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object