Package org.ldaptive.pool
Class IdlePruneStrategy
- java.lang.Object
-
- org.ldaptive.pool.AbstractPruneStrategy
-
- org.ldaptive.pool.IdlePruneStrategy
-
- All Implemented Interfaces:
Function<PooledConnectionProxy,Boolean>
,PruneStrategy
public class IdlePruneStrategy extends AbstractPruneStrategy
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IdlePruneStrategy.Builder
Idle 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 Duration
DEFAULT_IDLE_TIME
Default idle time.private static int
DEFAULT_STATISTICS_SIZE
Default number of statistics to store.private Duration
idleTime
Idle time.-
Fields inherited from class org.ldaptive.pool.AbstractPruneStrategy
DEFAULT_PRUNE_PERIOD, 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Boolean
apply(PooledConnectionProxy conn)
static IdlePruneStrategy.Builder
builder()
Creates a builder for this class.Duration
getIdleTime()
Returns the idle time.int
getStatisticsSize()
Returns the number of statistics to store for this prune strategy.void
setIdleTime(Duration time)
Sets the idle time.String
toString()
-
Methods inherited from class org.ldaptive.pool.AbstractPruneStrategy
getPrunePeriod, setPrunePeriod
-
-
-
-
Field Detail
-
DEFAULT_STATISTICS_SIZE
private static final int DEFAULT_STATISTICS_SIZE
Default number of statistics to store. Value is 1.- See Also:
- Constant Field Values
-
DEFAULT_IDLE_TIME
private static final Duration DEFAULT_IDLE_TIME
Default idle time. Value is 10 minutes.
-
idleTime
private Duration idleTime
Idle time.
-
-
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
-
-
Method Detail
-
apply
public Boolean apply(PooledConnectionProxy conn)
-
getStatisticsSize
public int getStatisticsSize()
Description copied from interface:PruneStrategy
Returns the number of statistics to store for this prune strategy. SeePooledConnectionStatistics
.- 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
-
builder
public static IdlePruneStrategy.Builder builder()
Creates a builder for this class.- Returns:
- new builder
-
-