Package org.ldaptive.pool
Class AgePruneStrategy
- java.lang.Object
-
- org.ldaptive.AbstractFreezable
-
- org.ldaptive.pool.AbstractPruneStrategy
-
- org.ldaptive.pool.AgePruneStrategy
-
- All Implemented Interfaces:
Consumer<Supplier<Iterator<PooledConnectionProxy>>>,Freezable,PruneStrategy
- Direct Known Subclasses:
IdlePruneStrategy
public class AgePruneStrategy extends AbstractPruneStrategy
Removes connections from the pool based on how long they have existed. By default, this implementation executes every 30 minutes and prunes connections that have existed for more than 1 hour. Setting an age time of zero means that no connections will be pruned by this strategy. This strategy will prune available connections below the minimum pool size. This strategy will also only prune connections that have a higher priority ifprunePriorityis set. The higher the priority the quicker the connection will be removed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAgePruneStrategy.BuilderAge 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 DurationageTimeAge time.private static DurationDEFAULT_AGE_TIMEDefault age time.private longprunePriorityThreshold at which to prune connections based on their priority.private intprunePriorityFactorFactor to apply toLdapURL.getPriority()in order to provide inverse backoff of the ageTime based on priority.-
Fields inherited from class org.ldaptive.pool.AbstractPruneStrategy
logger
-
-
Constructor Summary
Constructors Constructor Description AgePruneStrategy()Creates a new age prune strategy.AgePruneStrategy(Duration age)Creates a new age prune strategy.AgePruneStrategy(Duration period, Duration age)Creates a new age prune strategy.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AgePruneStrategy.Builderbuilder()Creates a builder for this class.DurationgetAgeTime()Returns the age time.List<Predicate<PooledConnectionProxy>>getPruneConditions()Returns the predicates used by this prune strategy.longgetPrunePriority()Returns the prune priority.intgetPrunePriorityFactor()Returns the prune priority factor.intgetStatisticsSize()Returns the number of statistics to store for this prune strategy.voidsetAgeTime(Duration time)Sets the age time.voidsetPrunePriority(long l)Sets the prune priority.voidsetPrunePriorityFactor(int i)Sets the prune priority factor.StringtoString()-
Methods inherited from class org.ldaptive.pool.AbstractPruneStrategy
accept, getPrunePeriod, setPrunePeriod
-
Methods inherited from class org.ldaptive.AbstractFreezable
assertMutable, freeze, freeze, freeze, isFrozen
-
-
-
-
Field Detail
-
DEFAULT_AGE_TIME
private static final Duration DEFAULT_AGE_TIME
Default age time. Value is 1 hour.
-
ageTime
private Duration ageTime
Age time.
-
prunePriority
private long prunePriority
Threshold at which to prune connections based on their priority. Connections with a priority >= to this value will be pruned.
-
prunePriorityFactor
private int prunePriorityFactor
Factor to apply toLdapURL.getPriority()in order to provide inverse backoff of the ageTime based on priority.
-
-
Constructor Detail
-
AgePruneStrategy
public AgePruneStrategy()
Creates a new age prune strategy.
-
AgePruneStrategy
public AgePruneStrategy(Duration age)
Creates a new age prune strategy. Sets the prune period to half of the supplied age time.- Parameters:
age- 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.- Specified by:
getPruneConditionsin classAbstractPruneStrategy- 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.- Returns:
- number of statistics to store
-
getAgeTime
public Duration getAgeTime()
Returns the age time.- Returns:
- age time
-
setAgeTime
public void setAgeTime(Duration time)
Sets the age time.- Parameters:
time- since a connection has been created and should be pruned
-
getPrunePriority
public long getPrunePriority()
Returns the prune priority.- Returns:
- priority value at which to prune
-
setPrunePriority
public void setPrunePriority(long l)
Sets the prune priority.- Parameters:
l- priority value at which to prune
-
getPrunePriorityFactor
public int getPrunePriorityFactor()
Returns the prune priority factor.- Returns:
- factor to multiply by URL priority for inverse backoff of ageTime
-
setPrunePriorityFactor
public void setPrunePriorityFactor(int i)
Sets the prune priority factor.- Parameters:
i- prune priority factor
-
builder
public static AgePruneStrategy.Builder builder()
Creates a builder for this class.- Returns:
- new builder
-
-