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
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 if
prunePriority is set.
The higher the priority the quicker the connection will be removed.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAge prune strategy builder.Nested classes/interfaces inherited from class org.ldaptive.pool.AbstractPruneStrategy
AbstractPruneStrategy.AbstractBuilder<B,T extends AbstractPruneStrategy> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DurationAge time.private static final DurationDefault age time.private intThreshold at which to prune connections based on their priority.private intFactor 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
ConstructorsConstructorDescriptionCreates 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
Modifier and TypeMethodDescriptionstatic AgePruneStrategy.Builderbuilder()Creates a builder for this class.Returns the age time.Returns the predicates used by this prune strategy.intReturns the prune priority.intReturns the prune priority factor.intReturns the number of statistics to store for this prune strategy.voidsetAgeTime(Duration time) Sets the age time.voidsetPrunePriority(int i) Sets the prune priority.voidsetPrunePriorityFactor(int i) Sets the prune priority factor.toString()Methods inherited from class org.ldaptive.pool.AbstractPruneStrategy
accept, getPrunePeriod, setPrunePeriodMethods inherited from class org.ldaptive.AbstractFreezable
assertMutable, freeze, freeze, freeze, isFrozen
-
Field Details
-
DEFAULT_AGE_TIME
Default age time. Value is 1 hour. -
ageTime
Age time. -
prunePriority
private int prunePriorityThreshold at which to prune connections based on their priority. Connections with a priority >= to this value will be pruned. -
prunePriorityFactor
private int prunePriorityFactorFactor to apply toLdapURL.getPriority()in order to provide inverse backoff of the ageTime based on priority.
-
-
Constructor Details
-
AgePruneStrategy
public AgePruneStrategy()Creates a new age prune strategy. -
AgePruneStrategy
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
-
AgePruneStrategy
Creates a new age prune strategy.- Parameters:
period- to execute the prune taskage- 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.- 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
Returns the age time.- Returns:
- age time
-
setAgeTime
Sets the age time.- Parameters:
time- since a connection has been created and should be pruned
-
getPrunePriority
public int getPrunePriority()Returns the prune priority.- Returns:
- priority value at which to prune
-
setPrunePriority
public void setPrunePriority(int i) Sets the prune priority.- Parameters:
i- 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
-
toString
-
builder
Creates a builder for this class.- Returns:
- new builder
-