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 DurationDefault idle time.private static final DurationDefault prune period in seconds.private static final intDefault number of statistics to store.private DurationIdle time.protected final org.slf4j.LoggerLogger for this class.private DurationPrune 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.intReturns the number of statistics to store for this prune strategy.voidsetIdleTime(Duration time) Sets the idle time.voidsetPrunePeriod(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:
applyin interfaceFunction<PooledConnectionProxy,Boolean>
-
getStatisticsSize
public int getStatisticsSize()Description copied from interface:PruneStrategyReturns the number of statistics to store for this prune strategy. SeePooledConnectionStatistics.- Specified by:
getStatisticsSizein interfacePruneStrategy- Returns:
- number of statistics to store
-
getPrunePeriod
Description copied from interface:PruneStrategyReturns the interval at which the prune task will be executed.- Specified by:
getPrunePeriodin 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
-