Package io.lettuce.core.support
Class BoundedPoolConfig.Builder
- java.lang.Object
-
- io.lettuce.core.support.BasePoolConfig.Builder
-
- io.lettuce.core.support.BoundedPoolConfig.Builder
-
- Enclosing class:
- BoundedPoolConfig
public static class BoundedPoolConfig.Builder extends BasePoolConfig.Builder
Builder forBoundedPoolConfig
.
-
-
Field Summary
-
Fields inherited from class io.lettuce.core.support.BasePoolConfig.Builder
testOnAcquire, testOnCreate, testOnRelease
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BoundedPoolConfig
build()
Build a newBasePoolConfig
object.BoundedPoolConfig.Builder
maxIdle(int maxIdle)
Returns the cap on the number of "idle" instances in the pool.BoundedPoolConfig.Builder
maxTotal(int maxTotal)
Configures the maximum number of objects that can be allocated by the pool (checked out to clients, or idle awaiting checkout) at a given time.BoundedPoolConfig.Builder
minIdle(int minIdle)
Configures the minimum number of idle objects to maintain in the pool.BoundedPoolConfig.Builder
testOnAcquire()
Enables validation of objects before being returned from the acquire method.BoundedPoolConfig.Builder
testOnAcquire(boolean testOnAcquire)
Configures whether objects acquired from the pool will be validated before being returned from the acquire method.BoundedPoolConfig.Builder
testOnCreate()
Enables validation of objects before being returned from the acquire method.BoundedPoolConfig.Builder
testOnCreate(boolean testOnCreate)
Configures whether objects created for the pool will be validated before being returned from the acquire method.BoundedPoolConfig.Builder
testOnRelease()
Enables validation of objects when they are returned to the pool via the release method.BoundedPoolConfig.Builder
testOnRelease(boolean testOnRelease)
Configures whether objects borrowed from the pool will be validated when they are returned to the pool via the release method.
-
-
-
Method Detail
-
testOnCreate
public BoundedPoolConfig.Builder testOnCreate()
Description copied from class:BasePoolConfig.Builder
Enables validation of objects before being returned from the acquire method. Validation is performed by theAsyncObjectFactory.validate(Object)
method of the factory associated with the pool. If the object fails to validate, then acquire will fail.- Overrides:
testOnCreate
in classBasePoolConfig.Builder
- Returns:
this
BasePoolConfig.Builder
.
-
testOnCreate
public BoundedPoolConfig.Builder testOnCreate(boolean testOnCreate)
Description copied from class:BasePoolConfig.Builder
Configures whether objects created for the pool will be validated before being returned from the acquire method. Validation is performed by theAsyncObjectFactory.validate(Object)
method of the factory associated with the pool. If the object fails to validate, then acquire will fail.- Overrides:
testOnCreate
in classBasePoolConfig.Builder
- Parameters:
testOnCreate
-true
if newly created objects should be validated before being returned from the acquire method.true
to enable test on creation.- Returns:
this
BasePoolConfig.Builder
.
-
testOnAcquire
public BoundedPoolConfig.Builder testOnAcquire()
Description copied from class:BasePoolConfig.Builder
Enables validation of objects before being returned from the acquire method. Validation is performed by theAsyncObjectFactory.validate(Object)
method of the factory associated with the pool. If the object fails to validate, it will be removed from the pool and destroyed, and a new attempt will be made to borrow an object from the pool.- Overrides:
testOnAcquire
in classBasePoolConfig.Builder
- Returns:
this
BasePoolConfig.Builder
.
-
testOnAcquire
public BoundedPoolConfig.Builder testOnAcquire(boolean testOnAcquire)
Description copied from class:BasePoolConfig.Builder
Configures whether objects acquired from the pool will be validated before being returned from the acquire method. Validation is performed by theAsyncObjectFactory.validate(Object)
method of the factory associated with the pool. If the object fails to validate, it will be removed from the pool and destroyed, and a new attempt will be made to borrow an object from the pool.- Overrides:
testOnAcquire
in classBasePoolConfig.Builder
- Parameters:
testOnAcquire
-true
if objects should be validated before being returned from the acquire method.- Returns:
this
BasePoolConfig.Builder
.
-
testOnRelease
public BoundedPoolConfig.Builder testOnRelease()
Description copied from class:BasePoolConfig.Builder
Enables validation of objects when they are returned to the pool via the release method. Validation is performed by theAsyncObjectFactory.validate(Object)
method of the factory associated with the pool. Returning objects that fail validation are destroyed rather then being returned the pool.- Overrides:
testOnRelease
in classBasePoolConfig.Builder
- Returns:
this
BasePoolConfig.Builder
.
-
testOnRelease
public BoundedPoolConfig.Builder testOnRelease(boolean testOnRelease)
Description copied from class:BasePoolConfig.Builder
Configures whether objects borrowed from the pool will be validated when they are returned to the pool via the release method. Validation is performed by theAsyncObjectFactory.validate(Object)
method of the factory associated with the pool. Returning objects that fail validation are destroyed rather then being returned the pool.- Overrides:
testOnRelease
in classBasePoolConfig.Builder
- Parameters:
testOnRelease
-true
if objects should be validated on return to the pool via the release method.- Returns:
this
BasePoolConfig.Builder
.
-
maxTotal
public BoundedPoolConfig.Builder maxTotal(int maxTotal)
Configures the maximum number of objects that can be allocated by the pool (checked out to clients, or idle awaiting checkout) at a given time. When negative, there is no limit to the number of objects that can be managed by the pool at one time.- Parameters:
maxTotal
- maximum number of objects that can be allocated by the pool.- Returns:
this
BoundedPoolConfig.Builder
.
-
maxIdle
public BoundedPoolConfig.Builder maxIdle(int maxIdle)
Returns the cap on the number of "idle" instances in the pool. IfmaxIdle
is set too low on heavily loaded systems it is possible you will see objects being destroyed and almost immediately new objects being created. This is a result of the active threads momentarily returning objects faster than they are requesting them, causing the number of idle objects to rise above maxIdle. The best value for maxIdle for heavily loaded system will vary but the default is a good starting point.- Parameters:
maxIdle
- the cap on the number of "idle" instances in the pool.- Returns:
this
BoundedPoolConfig.Builder
.
-
minIdle
public BoundedPoolConfig.Builder minIdle(int minIdle)
Configures the minimum number of idle objects to maintain in the pool. If this is the case, an attempt is made to ensure that the pool has the required minimum number of instances during idle object eviction runs.- Parameters:
minIdle
- minimum number of idle objects to maintain in the pool.- Returns:
this
BoundedPoolConfig.Builder
.
-
build
public BoundedPoolConfig build()
Build a newBasePoolConfig
object.- Returns:
- a new
BasePoolConfig
object.
-
-