Class 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.
    • 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
      • IdlePruneStrategy

        public IdlePruneStrategy​(Duration period,
                                 Duration idle)
        Creates a new idle prune strategy.
        Parameters:
        period - to execute the prune task
        idle - time at which a connection should be pruned
    • Method Detail

      • getStatisticsSize

        public int getStatisticsSize()
        Description copied from interface: PruneStrategy
        Returns the number of statistics to store for this prune strategy. See PooledConnectionStatistics.
        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