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
public class IdlePruneStrategy extends AgePruneStrategy
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 Classes Modifier and Type Class Description static classIdlePruneStrategy.BuilderIdle prune strategy builder.-
Nested classes/interfaces inherited from class org.ldaptive.pool.AbstractPruneStrategy
AbstractPruneStrategy.AbstractBuilder<B,T extends AbstractPruneStrategy>
-
-
Field Summary
Fields Modifier and Type Field Description private static DurationDEFAULT_IDLE_TIMEDefault idle time.private DurationidleTimeIdle time.-
Fields inherited from class org.ldaptive.pool.AbstractPruneStrategy
logger
-
-
Constructor Summary
Constructors Constructor Description IdlePruneStrategy()Creates 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static IdlePruneStrategy.Builderbuilder()Creates a builder for this class.DurationgetIdleTime()Returns the idle time.List<Predicate<PooledConnectionProxy>>getPruneConditions()Returns the predicates used by this prune strategy.intgetStatisticsSize()Returns the number of statistics to store for this prune strategy.voidsetIdleTime(Duration time)Sets the idle time.StringtoString()-
Methods inherited from class org.ldaptive.pool.AgePruneStrategy
getAgeTime, getPrunePriority, getPrunePriorityFactor, setAgeTime, setPrunePriority, setPrunePriorityFactor
-
Methods inherited from class org.ldaptive.pool.AbstractPruneStrategy
accept, getPrunePeriod, setPrunePeriod
-
Methods inherited from class org.ldaptive.AbstractFreezable
assertMutable, freeze, freeze, freeze, isFrozen
-
-
-
-
Constructor Detail
-
IdlePruneStrategy
public IdlePruneStrategy()
Creates a new idle prune strategy.
-
IdlePruneStrategy
public IdlePruneStrategy(Duration idle)
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
public IdlePruneStrategy(Duration period, Duration idle)
Creates a new idle prune strategy.- Parameters:
period- to execute the prune taskidle- time at which a connection should be pruned
-
-
Method Detail
-
getPruneConditions
public List<Predicate<PooledConnectionProxy>> 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
public Duration getIdleTime()
Returns the idle time.- Returns:
- idle time
-
setIdleTime
public void setIdleTime(Duration time)
Sets the idle time.- Parameters:
time- that a connection has been idle and should be pruned
-
toString
public String toString()
- Overrides:
toStringin classAgePruneStrategy
-
builder
public static IdlePruneStrategy.Builder builder()
Creates a builder for this class.- Returns:
- new builder
-
-