Package org.ldaptive.pool
Class IdlePruneStrategy
- java.lang.Object
-
- org.ldaptive.pool.IdlePruneStrategy
-
- All Implemented Interfaces:
java.util.function.Function<PooledConnectionProxy,java.lang.Boolean>
,PruneStrategy
public class IdlePruneStrategy extends java.lang.Object implements PruneStrategy
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.- Author:
- Middleware Services
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Logger
logger
Logger for this class.
-
Constructor Summary
Constructors Constructor Description IdlePruneStrategy()
Creates a new idle prune strategy.IdlePruneStrategy(java.time.Duration idle)
Creates a new idle prune strategy.IdlePruneStrategy(java.time.Duration period, java.time.Duration idle)
Creates a new idle prune strategy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Boolean
apply(PooledConnectionProxy conn)
java.time.Duration
getIdleTime()
Returns the idle time.java.time.Duration
getPrunePeriod()
Returns the interval at which the prune task will be executed.int
getStatisticsSize()
Returns the number of statistics to store for this prune strategy.void
setIdleTime(java.time.Duration time)
Sets the idle time.void
setPrunePeriod(java.time.Duration period)
Sets the prune period.java.lang.String
toString()
-
-
-
Constructor Detail
-
IdlePruneStrategy
public IdlePruneStrategy()
Creates a new idle prune strategy.
-
IdlePruneStrategy
public IdlePruneStrategy(java.time.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(java.time.Duration period, java.time.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
-
apply
public java.lang.Boolean apply(PooledConnectionProxy conn)
- Specified by:
apply
in interfacejava.util.function.Function<PooledConnectionProxy,java.lang.Boolean>
-
getStatisticsSize
public int getStatisticsSize()
Description copied from interface:PruneStrategy
Returns the number of statistics to store for this prune strategy. SeePooledConnectionStatistics
.- Specified by:
getStatisticsSize
in interfacePruneStrategy
- Returns:
- number of statistics to store
-
getPrunePeriod
public java.time.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(java.time.Duration period)
Sets the prune period.- Parameters:
period
- to set
-
getIdleTime
public java.time.Duration getIdleTime()
Returns the idle time.- Returns:
- idle time
-
setIdleTime
public void setIdleTime(java.time.Duration time)
Sets the idle time.- Parameters:
time
- that a connection has been idle and should be pruned
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-