Package org.ldaptive.pool
Class IdlePruneStrategy
java.lang.Object
org.ldaptive.AbstractFreezable
org.ldaptive.pool.AbstractPruneStrategy
org.ldaptive.pool.AgePruneStrategy
org.ldaptive.pool.IdlePruneStrategy
- All Implemented Interfaces:
Consumer<Supplier<Iterator<PooledConnectionProxy>>>,Freezable,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. This
strategy will not prune available connections below the minimum pool size unless an age time is configured.
Connections will be pruned by age before they are pruned by idle time.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classIdle prune strategy builder.Nested classes/interfaces inherited from class org.ldaptive.pool.AbstractPruneStrategy
AbstractPruneStrategy.AbstractBuilder<B,T extends AbstractPruneStrategy> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final DurationDefault idle time.private DurationIdle time.Fields inherited from class org.ldaptive.pool.AbstractPruneStrategy
logger -
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.IdlePruneStrategy(Duration period, Duration idle, Duration age) Creates a new idle prune strategy. -
Method Summary
Modifier and TypeMethodDescriptionstatic IdlePruneStrategy.Builderbuilder()Creates a builder for this class.Returns the idle time.Returns the predicates used by this prune strategy.intReturns the number of statistics to store for this prune strategy.voidsetIdleTime(Duration time) Sets the idle time.toString()Methods inherited from class org.ldaptive.pool.AgePruneStrategy
getAgeTime, getPrunePriority, getPrunePriorityFactor, setAgeTime, setPrunePriority, setPrunePriorityFactorMethods inherited from class org.ldaptive.pool.AbstractPruneStrategy
accept, getPrunePeriod, setPrunePeriodMethods inherited from class org.ldaptive.AbstractFreezable
assertMutable, freeze, freeze, freeze, isFrozen
-
Field Details
-
DEFAULT_IDLE_TIME
Default idle time. Value is 10 minutes. -
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
-
IdlePruneStrategy
Creates a new idle prune strategy.- Parameters:
period- to execute the prune taskidle- time at which a connection should be prunedage- time at which a connection should be pruned
-
-
Method Details
-
getPruneConditions
Description copied from class:AbstractPruneStrategyReturns the predicates used by this prune strategy. Each predicate will be invoked for every connection to be pruned.- Overrides:
getPruneConditionsin classAgePruneStrategy- Returns:
- List of predicates that are evaluated in order. Connections are removed from the pool immediately upon predicate returning true; subsequent predicates operate on a reduced pool.
-
getStatisticsSize
public int getStatisticsSize()Description copied from interface:PruneStrategyReturns the number of statistics to store for this prune strategy. SeePooledConnectionStatistics.- Specified by:
getStatisticsSizein interfacePruneStrategy- Overrides:
getStatisticsSizein classAgePruneStrategy- Returns:
- number of statistics to store
-
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
- Overrides:
toStringin classAgePruneStrategy
-
builder
Creates a builder for this class.- Returns:
- new builder
-