Class PoolOptions
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintGet how often the connection pool will be cleaned.longGet how long a connection can exist before it is recycled during connection pool cleaning.intGet the maximum size of the connection pool.intGet the maximum number of requests waiting for a connection from the pool.getName()Get the connection pool name to be used for metrics reporting.intGet how long a connection can stay unused before it is recycled during connection pool cleaning.setCleanerInterval(int cleanerInterval) Set how often the connection pool will be cleaned.setMaxLifetime(long maxLifetime) Set how long a connection can exist before it is recycled during connection pool cleaning.setMaxSize(int maxSize) Set the maximum size of the connection pool.setMaxWaiting(int maxWaiting) Set the maximum number of requests waiting for a connection from the pool.Set the connection pool name to be used for metrics reporting.setRecycleTimeout(int recycleTimeout) Set how long a connection can stay unused before it is recycled during connection pool cleaning.toJson()Converts this object to JSON notation.
-
Constructor Details
-
PoolOptions
public PoolOptions() -
PoolOptions
-
PoolOptions
-
-
Method Details
-
getName
Get the connection pool name to be used for metrics reporting. The default name is a random UUID.- Returns:
- the pool name
-
setName
Set the connection pool name to be used for metrics reporting. The default name is a random UUID.- Parameters:
name- the pool name- Returns:
- fluent self
-
getCleanerInterval
public int getCleanerInterval()Get how often the connection pool will be cleaned. Cleaning the connection pool means scanning for unused, too old and invalid connections and if any are found, they are forcibly closed and evicted from the pool.A connection is marked invalid if it enters a exception or fatal state. It is marked unused if it is unused for longer than the recycle timeout. It is marked too old if it exists longer than the maximum lifetime.
The return value is in milliseconds. By default, the cleaning interval is 30 seconds. The value of -1 means connection pool cleaning is disabled.
- Returns:
- the cleaning interval in milliseconds, or -1 for never
-
setCleanerInterval
Set how often the connection pool will be cleaned. Cleaning the connection pool means scanning for unused, too old and invalid connections and if any are found, they are forcibly closed and evicted from the pool.A connection is marked invalid if it enters a exception or fatal state. It is marked unused if it is unused for longer than the recycle timeout. It is marked too old if it exists longer than the maximum lifetime.
The value is in milliseconds. By default, the cleaning interval is 30 seconds. The value of -1 means connection pool cleaning is disabled.
- Parameters:
cleanerInterval- the cleaning interval in milliseconds, or -1 for never- Returns:
- fluent self
-
getMaxSize
public int getMaxSize()Get the maximum size of the connection pool.By default, the maximum pool size is 6.
- Returns:
- the maximum pool size
-
setMaxSize
Set the maximum size of the connection pool.By default, the maximum pool size is 6.
When working with cluster or sentinel, this value should be at least the total number of cluster member (or number of sentinels + 1).
- Parameters:
maxSize- the maximum pool size- Returns:
- fluent self
-
getMaxWaiting
public int getMaxWaiting()Get the maximum number of requests waiting for a connection from the pool.By default, the maximum number of waiting requests size is 24.
- Returns:
- the maximum number of waiting requests
-
setMaxWaiting
Set the maximum number of requests waiting for a connection from the pool.By default, the maximum number of waiting requests size is 24.
- Parameters:
maxWaiting- the maximum number of waiting requests- Returns:
- fluent self
-
getRecycleTimeout
public int getRecycleTimeout()Get how long a connection can stay unused before it is recycled during connection pool cleaning.The value is in milliseconds. By default, the recycle timeout is 3 minutes. The value of -1 means connection recycling is disabled.
- Returns:
- the recycle timeout
-
setRecycleTimeout
Set how long a connection can stay unused before it is recycled during connection pool cleaning.The value is in milliseconds. By default, the recycle timeout is 3 minutes. The value of -1 means connection recycling is disabled.
- Parameters:
recycleTimeout- the recycle timeout- Returns:
- fluent self
-
getMaxLifetime
public long getMaxLifetime()Get how long a connection can exist before it is recycled during connection pool cleaning.The value is in milliseconds. By default, the maximum lifetime is -1. The value of -1 means connections are never too old.
As opposed to recycle timeout, this property does not take into account when the connection was last used. If the connection is too old, it is evicted even if it was used very recently.
- Returns:
- the maximum lifetime
-
setMaxLifetime
Set how long a connection can exist before it is recycled during connection pool cleaning.The value is in milliseconds. By default, the maximum lifetime is -1. The value of -1 means connections are never too old.
As opposed to recycle timeout, this property does not take into account when the connection was last used. If the connection is too old, it is evicted even if it was used very recently.
- Parameters:
maxLifetime- the maximum lifetime- Returns:
- fluent self
-
toJson
-