@NotThreadSafe public static class ConnectionPoolSettings.Builder extends Object
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
ConnectionPoolSettings.Builder |
applyConnectionString(ConnectionString connectionString)
Takes connection pool settings from the given connection string and applies them to this builder.
|
ConnectionPoolSettings |
build()
Creates a new ConnectionPoolSettings object with the settings initialised on this builder.
|
ConnectionPoolSettings.Builder |
maintenanceFrequency(long maintenanceFrequency,
TimeUnit timeUnit)
The time period between runs of the maintenance job.
|
ConnectionPoolSettings.Builder |
maintenanceInitialDelay(long maintenanceInitialDelay,
TimeUnit timeUnit)
The period of time to wait before running the first maintenance job on the connection pool.
|
ConnectionPoolSettings.Builder |
maxConnectionIdleTime(long maxConnectionIdleTime,
TimeUnit timeUnit)
The maximum idle time of a pooled connection.
|
ConnectionPoolSettings.Builder |
maxConnectionLifeTime(long maxConnectionLifeTime,
TimeUnit timeUnit)
The maximum time a pooled connection can live for.
|
ConnectionPoolSettings.Builder |
maxSize(int maxSize)
The maximum number of connections allowed.
|
ConnectionPoolSettings.Builder |
maxWaitQueueSize(int maxWaitQueueSize)
This is the maximum number of waiters for a connection to become available from the pool.
|
ConnectionPoolSettings.Builder |
maxWaitTime(long maxWaitTime,
TimeUnit timeUnit)
The maximum time that a thread may wait for a connection to become available.
|
ConnectionPoolSettings.Builder |
minSize(int minSize)
The minimum number of connections.
|
public ConnectionPoolSettings.Builder maxSize(int maxSize)
The maximum number of connections allowed. Those connections will be kept in the pool when idle. Once the pool is exhausted, any operation requiring a connection will block waiting for an available connection.
Default is 100.
maxSize
- the maximum number of connections in the pool.public ConnectionPoolSettings.Builder minSize(int minSize)
The minimum number of connections. Those connections will be kept in the pool when idle, and the pool will ensure that it contains at least this minimum number.
Default is 0.
minSize
- the minimum number of connections to have in the pool at all times.public ConnectionPoolSettings.Builder maxWaitQueueSize(int maxWaitQueueSize)
This is the maximum number of waiters for a connection to become available from the pool. All further operations will get an exception immediately.
Default is 500.
maxWaitQueueSize
- the number of threads that are allowed to be waiting for a connection.public ConnectionPoolSettings.Builder maxWaitTime(long maxWaitTime, TimeUnit timeUnit)
The maximum time that a thread may wait for a connection to become available.
Default is 2 minutes. A value of 0 means that it will not wait. A negative value means it will wait indefinitely.
maxWaitTime
- the maximum amount of time to waittimeUnit
- the TimeUnit for this wait periodpublic ConnectionPoolSettings.Builder maxConnectionLifeTime(long maxConnectionLifeTime, TimeUnit timeUnit)
maxConnectionLifeTime
- the maximum length of time a connection can livetimeUnit
- the TimeUnit for this time periodpublic ConnectionPoolSettings.Builder maxConnectionIdleTime(long maxConnectionIdleTime, TimeUnit timeUnit)
maxConnectionIdleTime
- the maximum time a connection can be unusedtimeUnit
- the TimeUnit for this time periodpublic ConnectionPoolSettings.Builder maintenanceInitialDelay(long maintenanceInitialDelay, TimeUnit timeUnit)
maintenanceInitialDelay
- the time period to waittimeUnit
- the TimeUnit for this time periodpublic ConnectionPoolSettings.Builder maintenanceFrequency(long maintenanceFrequency, TimeUnit timeUnit)
maintenanceFrequency
- the time period between runs of the maintenance jobtimeUnit
- the TimeUnit for this time periodpublic ConnectionPoolSettings build()
public ConnectionPoolSettings.Builder applyConnectionString(ConnectionString connectionString)
connectionString
- a URL with details of how to connect to MongoDB