Package org.ldaptive.pool
Class IdlePruneStrategy
java.lang.Object
org.ldaptive.pool.IdlePruneStrategy
- All Implemented Interfaces:
Function<PooledConnectionProxy,
,Boolean> PruneStrategy
Removes connections from the pool based on how long they have been idle in the available queue. By default this
implementation executes every 5 minutes and prunes connections that have been idle for more than 10 minutes.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Duration
Default idle time.private static final Duration
Default prune period in seconds.private static final int
Default number of statistics to store.private Duration
Idle time.protected final org.slf4j.Logger
Logger for this class.private Duration
Prune period. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new idle prune strategy.IdlePruneStrategy
(Duration idle) Creates a new idle prune strategy.IdlePruneStrategy
(Duration period, Duration idle) Creates a new idle prune strategy. -
Method Summary
Modifier and TypeMethodDescriptionapply
(PooledConnectionProxy conn) Returns the idle time.Returns the interval at which the prune task will be executed.int
Returns the number of statistics to store for this prune strategy.void
setIdleTime
(Duration time) Sets the idle time.void
setPrunePeriod
(Duration period) Sets the prune period.toString()
-
Field Details
-
DEFAULT_STATISTICS_SIZE
private static final int DEFAULT_STATISTICS_SIZEDefault number of statistics to store. Value is 1.- See Also:
-
DEFAULT_PRUNE_PERIOD
Default prune period in seconds. Value is 5 minutes. -
DEFAULT_IDLE_TIME
Default idle time. Value is 10 minutes. -
logger
protected final org.slf4j.Logger loggerLogger for this class. -
prunePeriod
Prune period. -
idleTime
Idle time.
-
-
Constructor Details
-
IdlePruneStrategy
public IdlePruneStrategy()Creates a new idle prune strategy. -
IdlePruneStrategy
Creates a new idle prune strategy. Sets the prune period to half of the supplied idle time.- Parameters:
idle
- time at which a connection should be pruned
-
IdlePruneStrategy
Creates a new idle prune strategy.- Parameters:
period
- to execute the prune taskidle
- time at which a connection should be pruned
-
-
Method Details
-
apply
- Specified by:
apply
in interfaceFunction<PooledConnectionProxy,
Boolean>
-
getStatisticsSize
public int getStatisticsSize()Description copied from interface:PruneStrategy
Returns the number of statistics to store for this prune strategy. SeePooledConnectionStatistics
.- Specified by:
getStatisticsSize
in interfacePruneStrategy
- Returns:
- number of statistics to store
-
getPrunePeriod
Description copied from interface:PruneStrategy
Returns the interval at which the prune task will be executed.- Specified by:
getPrunePeriod
in interfacePruneStrategy
- Returns:
- prune period
-
setPrunePeriod
Sets the prune period.- Parameters:
period
- to set
-
getIdleTime
Returns the idle time.- Returns:
- idle time
-
setIdleTime
Sets the idle time.- Parameters:
time
- that a connection has been idle and should be pruned
-
toString
-