Package org.ldaptive.pool
Class AbstractPruneStrategy
- java.lang.Object
-
- org.ldaptive.AbstractFreezable
-
- org.ldaptive.pool.AbstractPruneStrategy
-
- All Implemented Interfaces:
Consumer<Supplier<Iterator<PooledConnectionProxy>>>
,Freezable
,PruneStrategy
- Direct Known Subclasses:
AgePruneStrategy
public abstract class AbstractPruneStrategy extends AbstractFreezable implements PruneStrategy
Base class for prune strategy implementations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractPruneStrategy.AbstractBuilder<B,T extends AbstractPruneStrategy>
Base class for prune strategy builders.
-
Field Summary
Fields Modifier and Type Field Description protected Logger
logger
Logger for this class.private Duration
prunePeriod
Prune period.
-
Constructor Summary
Constructors Constructor Description AbstractPruneStrategy()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
accept(Supplier<Iterator<PooledConnectionProxy>> connections)
protected abstract List<Predicate<PooledConnectionProxy>>
getPruneConditions()
Returns the predicates used by this prune strategy.Duration
getPrunePeriod()
Returns the interval at which the prune task will be executed.void
setPrunePeriod(Duration period)
Sets the prune period.-
Methods inherited from class org.ldaptive.AbstractFreezable
assertMutable, freeze, freeze, freeze, isFrozen
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ldaptive.pool.PruneStrategy
getStatisticsSize
-
-
-
-
Method Detail
-
getPrunePeriod
public Duration getPrunePeriod()
Description copied from interface:PruneStrategy
Returns the interval at which the prune task will be executed.- Specified by:
getPrunePeriod
in interfacePruneStrategy
- Returns:
- prune period
-
setPrunePeriod
public void setPrunePeriod(Duration period)
Sets the prune period.- Parameters:
period
- to set
-
accept
public void accept(Supplier<Iterator<PooledConnectionProxy>> connections)
- Specified by:
accept
in interfaceConsumer<Supplier<Iterator<PooledConnectionProxy>>>
-
getPruneConditions
protected abstract List<Predicate<PooledConnectionProxy>> getPruneConditions()
Returns the predicates used by this prune strategy. Each predicate will be invoked for every connection to be pruned.- 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.
-
-